• Home
Name Date Size #Lines LOC

..--

.github/03-May-2024-125

all/03-May-2024-8270

alts/03-May-2024-26,62417,827

android/03-May-2024-1,027787

android-interop-testing/03-May-2024-1,007790

annotation-stubs/03-May-2024-10780

auth/03-May-2024-1,244936

benchmarks/03-May-2024-45,50432,775

buildscripts/03-May-2024-1,220809

compiler/03-May-2024-5,0174,442

context/03-May-2024-3,6392,406

core/03-May-2024-65,46343,357

cronet/03-May-2024-2,4691,844

documentation/03-May-2024-230175

examples/03-May-2024-10,5077,785

gae-interop-testing/03-May-2024-950744

gradle/wrapper/03-May-2024-65

grpclb/03-May-2024-11,7988,275

interop-testing/03-May-2024-23,18017,057

netty/03-May-2024-17,12712,180

okhttp/03-May-2024-13,4189,097

protobuf/03-May-2024-712378

protobuf-lite/03-May-2024-798577

protobuf-nano/03-May-2024-586401

services/03-May-2024-80,59357,393

stub/03-May-2024-3,3302,054

testing/03-May-2024-5,9524,206

testing-proto/03-May-2024-1,9941,514

.gitattributesD03-May-2024214 76

.gitignoreD03-May-2024300 3629

.travis.ymlD03-May-20242.4 KiB6645

AUTHORSD03-May-202412 21

Android.bpD03-May-20241.9 KiB6863

BUILD.bazelD03-May-2024889 2723

COMPILING.mdD03-May-20243.9 KiB11896

CONTRIBUTING.mdD03-May-20244.3 KiB8451

LICENSED03-May-202411.1 KiB203169

METADATAD03-May-202439 43

NOTICE.txtD03-May-20241.2 KiB3728

OWNERSD03-May-2024155 54

README.mdD03-May-20247.4 KiB221182

RELEASING.mdD03-May-20248.8 KiB225189

SECURITY.mdD03-May-202421.6 KiB419315

WORKSPACED03-May-2024119 63

build.gradleD03-May-202419.3 KiB510460

codecov.ymlD03-May-2024245 1514

gradlewD03-May-20245.2 KiB173128

gradlew.batD03-May-20242.2 KiB8561

java_grpc_library.bzlD03-May-20244.4 KiB134122

repositories.bzlD03-May-202411.8 KiB334300

run-test-client.shD03-May-2024376 108

run-test-server.shD03-May-2024376 108

settings.gradleD03-May-20242.2 KiB5047

README.md

1gRPC-Java - An RPC library and framework
2========================================
3
4gRPC-Java works with JDK 7. gRPC-Java clients are supported on Android API
5levels 14 and up (Ice Cream Sandwich and later). Deploying gRPC servers on an
6Android device is not supported.
7
8TLS usage typically requires using Java 8, or Play Services Dynamic Security
9Provider on Android. Please see the [Security Readme](SECURITY.md).
10
11<table>
12  <tr>
13    <td><b>Homepage:</b></td>
14    <td><a href="https://grpc.io/">grpc.io</a></td>
15  </tr>
16  <tr>
17    <td><b>Mailing List:</b></td>
18    <td><a href="https://groups.google.com/forum/#!forum/grpc-io">grpc-io@googlegroups.com</a></td>
19  </tr>
20</table>
21
22[![Join the chat at https://gitter.im/grpc/grpc](https://badges.gitter.im/grpc/grpc.svg)](https://gitter.im/grpc/grpc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
23[![Build Status](https://travis-ci.org/grpc/grpc-java.svg?branch=master)](https://travis-ci.org/grpc/grpc-java)
24[![Coverage Status](https://coveralls.io/repos/grpc/grpc-java/badge.svg?branch=master&service=github)](https://coveralls.io/github/grpc/grpc-java?branch=master)
25
26Getting Started
27---------------
28
29For a guided tour, take a look at the [quick start
30guide](https://grpc.io/docs/quickstart/java.html) or the more explanatory [gRPC
31basics](https://grpc.io/docs/tutorials/basic/java.html).
32
33The [examples](https://github.com/grpc/grpc-java/tree/v1.16.1/examples) and the
34[Android example](https://github.com/grpc/grpc-java/tree/v1.16.1/examples/android)
35are standalone projects that showcase the usage of gRPC.
36
37Download
38--------
39
40Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`:
41```xml
42<dependency>
43  <groupId>io.grpc</groupId>
44  <artifactId>grpc-netty-shaded</artifactId>
45  <version>1.16.1</version>
46</dependency>
47<dependency>
48  <groupId>io.grpc</groupId>
49  <artifactId>grpc-protobuf</artifactId>
50  <version>1.16.1</version>
51</dependency>
52<dependency>
53  <groupId>io.grpc</groupId>
54  <artifactId>grpc-stub</artifactId>
55  <version>1.16.1</version>
56</dependency>
57```
58
59Or for Gradle with non-Android, add to your dependencies:
60```gradle
61compile 'io.grpc:grpc-netty-shaded:1.16.1'
62compile 'io.grpc:grpc-protobuf:1.16.1'
63compile 'io.grpc:grpc-stub:1.16.1'
64```
65
66For Android client, use `grpc-okhttp` instead of `grpc-netty-shaded` and
67`grpc-protobuf-lite` instead of `grpc-protobuf`:
68```gradle
69compile 'io.grpc:grpc-okhttp:1.16.1'
70compile 'io.grpc:grpc-protobuf-lite:1.16.1'
71compile 'io.grpc:grpc-stub:1.16.1'
72```
73
74[the JARs]:
75https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.16.1
76
77Development snapshots are available in [Sonatypes's snapshot
78repository](https://oss.sonatype.org/content/repositories/snapshots/).
79
80Generated Code
81--------------
82
83For protobuf-based codegen, you can put your proto files in the `src/main/proto`
84and `src/test/proto` directories along with an appropriate plugin.
85
86For protobuf-based codegen integrated with the Maven build system, you can use
87[protobuf-maven-plugin][] (Eclipse and NetBeans users should also look at
88`os-maven-plugin`'s
89[IDE documentation](https://github.com/trustin/os-maven-plugin#issues-with-eclipse-m2e-or-other-ides)):
90```xml
91<build>
92  <extensions>
93    <extension>
94      <groupId>kr.motd.maven</groupId>
95      <artifactId>os-maven-plugin</artifactId>
96      <version>1.5.0.Final</version>
97    </extension>
98  </extensions>
99  <plugins>
100    <plugin>
101      <groupId>org.xolstice.maven.plugins</groupId>
102      <artifactId>protobuf-maven-plugin</artifactId>
103      <version>0.5.1</version>
104      <configuration>
105        <protocArtifact>com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}</protocArtifact>
106        <pluginId>grpc-java</pluginId>
107        <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.16.1:exe:${os.detected.classifier}</pluginArtifact>
108      </configuration>
109      <executions>
110        <execution>
111          <goals>
112            <goal>compile</goal>
113            <goal>compile-custom</goal>
114          </goals>
115        </execution>
116      </executions>
117    </plugin>
118  </plugins>
119</build>
120```
121
122[protobuf-maven-plugin]: https://www.xolstice.org/protobuf-maven-plugin/
123
124For protobuf-based codegen integrated with the Gradle build system, you can use
125[protobuf-gradle-plugin][]:
126```gradle
127apply plugin: 'com.google.protobuf'
128
129buildscript {
130  repositories {
131    mavenCentral()
132  }
133  dependencies {
134    classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5'
135  }
136}
137
138protobuf {
139  protoc {
140    artifact = "com.google.protobuf:protoc:3.5.1-1"
141  }
142  plugins {
143    grpc {
144      artifact = 'io.grpc:protoc-gen-grpc-java:1.16.1'
145    }
146  }
147  generateProtoTasks {
148    all()*.plugins {
149      grpc {}
150    }
151  }
152}
153```
154
155[protobuf-gradle-plugin]: https://github.com/google/protobuf-gradle-plugin
156
157The prebuilt protoc-gen-grpc-java binary uses glibc on Linux. If you are
158compiling on Alpine Linux, you may want to use the [Alpine grpc-java package][]
159which uses musl instead.
160
161[Alpine grpc-java package]: https://pkgs.alpinelinux.org/package/edge/testing/x86_64/grpc-java
162
163API Stability
164-------------
165
166APIs annotated with `@Internal` are for internal use by the gRPC library and
167should not be used by gRPC users. APIs annotated with `@ExperimentalApi` are
168subject to change in future releases, and library code that other projects
169may depend on should not use these APIs.
170
171We recommend using the
172[grpc-java-api-checker](https://github.com/grpc/grpc-java-api-checker)
173(an [Error Prone](https://github.com/google/error-prone) plugin)
174to check for usages of `@ExperimentalApi` and `@Internal` in any library code
175that depends on gRPC. It may also be used to check for `@Internal` usage or
176unintended `@ExperimentalApi` consumption in non-library code.
177
178How to Build
179------------
180
181If you are making changes to gRPC-Java, see the [compiling
182instructions](COMPILING.md).
183
184High-level Components
185---------------------
186
187At a high level there are three distinct layers to the library: *Stub*,
188*Channel*, and *Transport*.
189
190### Stub
191
192The Stub layer is what is exposed to most developers and provides type-safe
193bindings to whatever datamodel/IDL/interface you are adapting. gRPC comes with
194a [plugin](https://github.com/google/grpc-java/blob/master/compiler) to the
195protocol-buffers compiler that generates Stub interfaces out of `.proto` files,
196but bindings to other datamodel/IDL are easy and encouraged.
197
198### Channel
199
200The Channel layer is an abstraction over Transport handling that is suitable for
201interception/decoration and exposes more behavior to the application than the
202Stub layer. It is intended to be easy for application frameworks to use this
203layer to address cross-cutting concerns such as logging, monitoring, auth, etc.
204
205### Transport
206
207The Transport layer does the heavy lifting of putting and taking bytes off the
208wire. The interfaces to it are abstract just enough to allow plugging in of
209different implementations. Note the transport layer API is considered internal
210to gRPC and has weaker API guarantees than the core API under package `io.grpc`.
211
212gRPC comes with three Transport implementations:
213
2141. The Netty-based transport is the main transport implementation based on
215   [Netty](http://netty.io). It is for both the client and the server.
2162. The OkHttp-based transport is a lightweight transport based on
217   [OkHttp](http://square.github.io/okhttp/). It is mainly for use on Android
218   and is for client only.
2193. The in-process transport is for when a server is in the same process as the
220   client. It is useful for testing, while also being safe for production use.
221