|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| .github/ | H | 25-Apr-2025 | - | 182 | 145 |
| all/ | H | 25-Apr-2025 | - | 78 | 67 |
| alts/ | H | 25-Apr-2025 | - | 12,017 | 8,256 |
| android/ | H | 25-Apr-2025 | - | 1,301 | 944 |
| android-interop-testing/ | H | 25-Apr-2025 | - | 6,993 | 4,925 |
| annotation-stubs/ | H | 25-Apr-2025 | - | 132 | 104 |
| api/ | H | 25-Apr-2025 | - | 24,807 | 13,171 |
| auth/ | H | 25-Apr-2025 | - | 1,360 | 1,011 |
| authz/ | H | 25-Apr-2025 | - | 1,985 | 1,723 |
| benchmarks/ | H | 25-Apr-2025 | - | 7,136 | 5,262 |
| binder/ | H | 25-Apr-2025 | - | 11,494 | 7,701 |
| bom/ | H | 25-Apr-2025 | - | 47 | 42 |
| buildscripts/ | H | 25-Apr-2025 | - | 2,448 | 1,520 |
| census/ | H | 25-Apr-2025 | - | 3,640 | 2,948 |
| compiler/ | H | 25-Apr-2025 | - | 4,464 | 3,886 |
| context/ | H | 25-Apr-2025 | - | 4,100 | 2,701 |
| core/ | H | 25-Apr-2025 | - | 70,268 | 51,119 |
| cronet/ | H | 25-Apr-2025 | - | 2,849 | 2,138 |
| documentation/ | H | 25-Apr-2025 | - | 610 | 489 |
| examples/ | H | 25-Apr-2025 | - | 18,496 | 13,389 |
| gae-interop-testing/ | H | 25-Apr-2025 | - | 517 | 394 |
| gcp-observability/ | H | 25-Apr-2025 | - | 6,592 | 5,236 |
| googleapis/ | H | 25-Apr-2025 | - | 911 | 721 |
| gradle/ | H | 25-Apr-2025 | - | 82 | 79 |
| grpclb/ | H | 25-Apr-2025 | - | 7,100 | 5,292 |
| interop-testing/ | H | 25-Apr-2025 | - | 15,699 | 12,099 |
| istio-interop-testing/ | H | 25-Apr-2025 | - | 1,687 | 1,359 |
| netty/ | H | 25-Apr-2025 | - | 25,300 | 18,470 |
| okhttp/ | H | 25-Apr-2025 | - | 21,543 | 15,425 |
| protobuf/ | H | 25-Apr-2025 | - | 742 | 395 |
| protobuf-lite/ | H | 25-Apr-2025 | - | 917 | 664 |
| rls/ | H | 25-Apr-2025 | - | 7,382 | 5,483 |
| services/ | H | 25-Apr-2025 | - | 15,037 | 11,497 |
| servlet/ | H | 25-Apr-2025 | - | 3,155 | 2,261 |
| stub/ | H | 25-Apr-2025 | - | 5,062 | 3,140 |
| testing/ | H | 25-Apr-2025 | - | 4,009 | 2,669 |
| testing-proto/ | H | 25-Apr-2025 | - | 772 | 565 |
| xds/ | H | 25-Apr-2025 | - | 99,340 | 79,862 |
| .bazelignore | H A D | 25-Apr-2025 | 130 | 4 | 3 |
| .bazelrc | H A D | 25-Apr-2025 | 51 | 2 | 1 |
| .gitattributes | H A D | 25-Apr-2025 | 136 | 5 | 4 |
| .gitignore | H A D | 25-Apr-2025 | 399 | 45 | 36 |
| AUTHORS | H A D | 25-Apr-2025 | 12 | 2 | 1 |
| Android.bp | H A D | 25-Apr-2025 | 3.3 KiB | 129 | 121 |
| BUILD.bazel | H A D | 25-Apr-2025 | 2 KiB | 72 | 64 |
| CODE-OF-CONDUCT.md | H A D | 25-Apr-2025 | 138 | 4 | 2 |
| COMPILING.md | H A D | 25-Apr-2025 | 5.9 KiB | 153 | 126 |
| CONTRIBUTING.md | H A D | 25-Apr-2025 | 4.6 KiB | 88 | 54 |
| GOVERNANCE.md | H A D | 25-Apr-2025 | 141 | 2 | 1 |
| LICENSE | H A D | 25-Apr-2025 | 11.1 KiB | 203 | 169 |
| MAINTAINERS.md | H A D | 25-Apr-2025 | 1.7 KiB | 35 | 31 |
| METADATA | H A D | 25-Apr-2025 | 314 | 17 | 15 |
| NOTICE.txt | H A D | 25-Apr-2025 | 2 KiB | 63 | 50 |
| OWNERS | H A D | 25-Apr-2025 | 58 | 4 | 3 |
| README.md | H A D | 25-Apr-2025 | 9.5 KiB | 280 | 232 |
| RELEASING.md | H A D | 25-Apr-2025 | 9.6 KiB | 237 | 197 |
| SECURITY.md | H A D | 25-Apr-2025 | 18.4 KiB | 428 | 339 |
| WORKSPACE | H A D | 25-Apr-2025 | 1.5 KiB | 48 | 34 |
| build.gradle | H A D | 25-Apr-2025 | 22.6 KiB | 578 | 524 |
| codecov.yml | H A D | 25-Apr-2025 | 245 | 15 | 14 |
| gradlew | H A D | 25-Apr-2025 | 7.9 KiB | 235 | 98 |
| gradlew.bat | H A D | 25-Apr-2025 | 2.7 KiB | 90 | 68 |
| java_grpc_library.bzl | H A D | 25-Apr-2025 | 6.9 KiB | 209 | 189 |
| repositories.bzl | H A D | 25-Apr-2025 | 7.3 KiB | 165 | 157 |
| run-test-client.sh | H A D | 25-Apr-2025 | 295 | 12 | 10 |
| run-test-server.sh | H A D | 25-Apr-2025 | 295 | 12 | 10 |
| settings.gradle | H A D | 25-Apr-2025 | 4.9 KiB | 115 | 110 |
README.md
1gRPC-Java - An RPC library and framework
2========================================
3
4<table>
5 <tr>
6 <td><b>Homepage:</b></td>
7 <td><a href="https://grpc.io/">grpc.io</a></td>
8 </tr>
9 <tr>
10 <td><b>Mailing List:</b></td>
11 <td><a href="https://groups.google.com/forum/#!forum/grpc-io">[email protected]</a></td>
12 </tr>
13</table>
14
15[](https://gitter.im/grpc/grpc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16[](https://travis-ci.org/grpc/grpc-java)
17[](https://coveralls.io/github/grpc/grpc-java?branch=master)
18[](https://codecov.io/gh/grpc/grpc-java)
19
20Supported Platforms
21-------------------
22
23gRPC-Java supports Java 8 and later. Android minSdkVersion 19 (KitKat) and
24later are supported with [Java 8 language desugaring][android-java-8].
25
26TLS usage on Android typically requires Play Services Dynamic Security Provider.
27Please see the [Security Readme](SECURITY.md).
28
29Older Java versions are not directly supported, but a branch remains available
30for fixes and releases. See [gRFC P5 JDK Version Support
31Policy][P5-jdk-version-support].
32
33Java version | gRPC Branch
34------------ | -----------
357 | 1.41.x
36
37[android-java-8]: https://developer.android.com/studio/write/java8-support#supported_features
38[P5-jdk-version-support]: https://github.com/grpc/proposal/blob/master/P5-jdk-version-support.md#proposal
39
40Getting Started
41---------------
42
43For a guided tour, take a look at the [quick start
44guide](https://grpc.io/docs/languages/java/quickstart) or the more explanatory [gRPC
45basics](https://grpc.io/docs/languages/java/basics).
46
47The [examples](https://github.com/grpc/grpc-java/tree/v1.56.0/examples) and the
48[Android example](https://github.com/grpc/grpc-java/tree/v1.56.0/examples/android)
49are standalone projects that showcase the usage of gRPC.
50
51Download
52--------
53
54Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`:
55```xml
56<dependency>
57 <groupId>io.grpc</groupId>
58 <artifactId>grpc-netty-shaded</artifactId>
59 <version>1.56.0</version>
60 <scope>runtime</scope>
61</dependency>
62<dependency>
63 <groupId>io.grpc</groupId>
64 <artifactId>grpc-protobuf</artifactId>
65 <version>1.56.0</version>
66</dependency>
67<dependency>
68 <groupId>io.grpc</groupId>
69 <artifactId>grpc-stub</artifactId>
70 <version>1.56.0</version>
71</dependency>
72<dependency> <!-- necessary for Java 9+ -->
73 <groupId>org.apache.tomcat</groupId>
74 <artifactId>annotations-api</artifactId>
75 <version>6.0.53</version>
76 <scope>provided</scope>
77</dependency>
78```
79
80Or for Gradle with non-Android, add to your dependencies:
81```gradle
82runtimeOnly 'io.grpc:grpc-netty-shaded:1.56.0'
83implementation 'io.grpc:grpc-protobuf:1.56.0'
84implementation 'io.grpc:grpc-stub:1.56.0'
85compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
86```
87
88For Android client, use `grpc-okhttp` instead of `grpc-netty-shaded` and
89`grpc-protobuf-lite` instead of `grpc-protobuf`:
90```gradle
91implementation 'io.grpc:grpc-okhttp:1.56.0'
92implementation 'io.grpc:grpc-protobuf-lite:1.56.0'
93implementation 'io.grpc:grpc-stub:1.56.0'
94compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
95```
96
97For [Bazel](https://bazel.build), you can either
98[use Maven](https://github.com/bazelbuild/rules_jvm_external)
99(with the GAVs from above), or use `@io_grpc_grpc_java//api` et al (see below).
100
101[the JARs]:
102https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.56.0
103
104Development snapshots are available in [Sonatypes's snapshot
105repository](https://oss.sonatype.org/content/repositories/snapshots/).
106
107Generated Code
108--------------
109
110For protobuf-based codegen, you can put your proto files in the `src/main/proto`
111and `src/test/proto` directories along with an appropriate plugin.
112
113For protobuf-based codegen integrated with the Maven build system, you can use
114[protobuf-maven-plugin][] (Eclipse and NetBeans users should also look at
115`os-maven-plugin`'s
116[IDE documentation](https://github.com/trustin/os-maven-plugin#issues-with-eclipse-m2e-or-other-ides)):
117```xml
118<build>
119 <extensions>
120 <extension>
121 <groupId>kr.motd.maven</groupId>
122 <artifactId>os-maven-plugin</artifactId>
123 <version>1.7.1</version>
124 </extension>
125 </extensions>
126 <plugins>
127 <plugin>
128 <groupId>org.xolstice.maven.plugins</groupId>
129 <artifactId>protobuf-maven-plugin</artifactId>
130 <version>0.6.1</version>
131 <configuration>
132 <protocArtifact>com.google.protobuf:protoc:3.22.3:exe:${os.detected.classifier}</protocArtifact>
133 <pluginId>grpc-java</pluginId>
134 <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.56.0:exe:${os.detected.classifier}</pluginArtifact>
135 </configuration>
136 <executions>
137 <execution>
138 <goals>
139 <goal>compile</goal>
140 <goal>compile-custom</goal>
141 </goals>
142 </execution>
143 </executions>
144 </plugin>
145 </plugins>
146</build>
147```
148
149[protobuf-maven-plugin]: https://www.xolstice.org/protobuf-maven-plugin/
150
151For non-Android protobuf-based codegen integrated with the Gradle build system,
152you can use [protobuf-gradle-plugin][]:
153```gradle
154plugins {
155 id 'com.google.protobuf' version '0.9.1'
156}
157
158protobuf {
159 protoc {
160 artifact = "com.google.protobuf:protoc:3.22.3"
161 }
162 plugins {
163 grpc {
164 artifact = 'io.grpc:protoc-gen-grpc-java:1.56.0'
165 }
166 }
167 generateProtoTasks {
168 all()*.plugins {
169 grpc {}
170 }
171 }
172}
173```
174
175[protobuf-gradle-plugin]: https://github.com/google/protobuf-gradle-plugin
176
177The prebuilt protoc-gen-grpc-java binary uses glibc on Linux. If you are
178compiling on Alpine Linux, you may want to use the [Alpine grpc-java package][]
179which uses musl instead.
180
181[Alpine grpc-java package]: https://pkgs.alpinelinux.org/package/edge/community/x86_64/grpc-java
182
183For Android protobuf-based codegen integrated with the Gradle build system, also
184use protobuf-gradle-plugin but specify the 'lite' options:
185
186```gradle
187plugins {
188 id 'com.google.protobuf' version '0.9.1'
189}
190
191protobuf {
192 protoc {
193 artifact = "com.google.protobuf:protoc:3.22.3"
194 }
195 plugins {
196 grpc {
197 artifact = 'io.grpc:protoc-gen-grpc-java:1.56.0'
198 }
199 }
200 generateProtoTasks {
201 all().each { task ->
202 task.builtins {
203 java { option 'lite' }
204 }
205 task.plugins {
206 grpc { option 'lite' }
207 }
208 }
209 }
210}
211
212```
213
214For [Bazel](https://bazel.build), use the [`proto_library`](https://github.com/bazelbuild/rules_proto)
215and the [`java_proto_library`](https://bazel.build/reference/be/java#java_proto_library) (no `load()` required)
216and `load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")` (from this project), as in
217[this example `BUILD.bazel`](https://github.com/grpc/grpc-java/blob/master/examples/BUILD.bazel).
218
219API Stability
220-------------
221
222APIs annotated with `@Internal` are for internal use by the gRPC library and
223should not be used by gRPC users. APIs annotated with `@ExperimentalApi` are
224subject to change in future releases, and library code that other projects
225may depend on should not use these APIs.
226
227We recommend using the
228[grpc-java-api-checker](https://github.com/grpc/grpc-java-api-checker)
229(an [Error Prone](https://github.com/google/error-prone) plugin)
230to check for usages of `@ExperimentalApi` and `@Internal` in any library code
231that depends on gRPC. It may also be used to check for `@Internal` usage or
232unintended `@ExperimentalApi` consumption in non-library code.
233
234How to Build
235------------
236
237If you are making changes to gRPC-Java, see the [compiling
238instructions](COMPILING.md).
239
240High-level Components
241---------------------
242
243At a high level there are three distinct layers to the library: *Stub*,
244*Channel*, and *Transport*.
245
246### Stub
247
248The Stub layer is what is exposed to most developers and provides type-safe
249bindings to whatever datamodel/IDL/interface you are adapting. gRPC comes with
250a [plugin](https://github.com/google/grpc-java/blob/master/compiler) to the
251protocol-buffers compiler that generates Stub interfaces out of `.proto` files,
252but bindings to other datamodel/IDL are easy and encouraged.
253
254### Channel
255
256The Channel layer is an abstraction over Transport handling that is suitable for
257interception/decoration and exposes more behavior to the application than the
258Stub layer. It is intended to be easy for application frameworks to use this
259layer to address cross-cutting concerns such as logging, monitoring, auth, etc.
260
261### Transport
262
263The Transport layer does the heavy lifting of putting and taking bytes off the
264wire. The interfaces to it are abstract just enough to allow plugging in of
265different implementations. Note the transport layer API is considered internal
266to gRPC and has weaker API guarantees than the core API under package `io.grpc`.
267
268gRPC comes with multiple Transport implementations:
269
2701. The Netty-based HTTP/2 transport is the main transport implementation based
271 on [Netty](https://netty.io). It is not officially supported on Android.
2722. The OkHttp-based HTTP/2 transport is a lightweight transport based on
273 [Okio](https://square.github.io/okio/) and forked low-level parts of
274 [OkHttp](https://square.github.io/okhttp/). It is mainly for use on Android.
2753. The in-process transport is for when a server is in the same process as the
276 client. It is used frequently for testing, while also being safe for
277 production use.
2784. The Binder transport is for Android cross-process communication on a single
279 device.
280