blob: f4b5e80d556645cc534ee7201351af2aaa544415 [file] [log] [blame] [view]
ejonad4531da2014-12-15 10:24:42 -08001grpc-java
2=========
3
Eric Andersonfb28ad22015-01-29 15:00:58 -08004How to Build
5------------
6
7grpc-java requires Netty 5, which is still in flux. The version we need can be
8found in the lib/netty submodule:
9```
10$ git submodule update --init
11$ cd lib/netty
12$ mvn install -pl codec-http2 -am -DskipTests=true
13```
14
15The codegen plugin requires a recent protobuf build from master (what will
16become proto3):
17```
18$ git clone https://github.com/google/protobuf.git
19$ cd protobuf
20$ ./autogen.sh
21$ ./configure
22$ make
23$ make check
24$ sudo make install
25$ cd java
26$ mvn install
27```
28
29If you are comfortable with C++ compilation and autotools, you can specify a
30--prefix for protobuf and use -I in CXXFLAGS, -L in LDFLAGS, LD\_LIBRARY\_PATH,
31and PATH to reference it. The environment variables will be used when building
32grpc-java.
33
34Now to build grpc-java itself:
35```
36$ ./gradlew install
37```
38
39Navigating Around the Source
40----------------------------
41
ejonad4531da2014-12-15 10:24:42 -080042Heres a quick readers guide to the code to help folks get started. At a high level there are three distinct layers
43to the library: stub, channel & transport.
44
Eric Andersonfb28ad22015-01-29 15:00:58 -080045### Stub
ejonad4531da2014-12-15 10:24:42 -080046
47The 'stub' layer is what is exposed to most developers and provides type-safe bindings to whatever
48datamodel/IDL/interface you are adapting. An example is provided of a binding to code generated by the protocol-buffers compiler but others should be trivial to add and are welcome.
49
50#### Key Interfaces
51
nmittlerf8314582015-01-27 10:25:39 -080052[Stream Observer](https://github.com/google/grpc-java/blob/master/stub/src/main/java/io/grpc/stub/StreamObserver.java)
ejonad4531da2014-12-15 10:24:42 -080053
54
Eric Andersonfb28ad22015-01-29 15:00:58 -080055### Channel
ejonad4531da2014-12-15 10:24:42 -080056
57The 'channel' layer is an abstraction over transport handling that is suitable for interception/decoration and exposes more behavior to the application than the stub layer. It is intended to be easy for application frameworks to use this layer to address cross-cutting concerns such as logging, monitoring, auth etc. Flow-control is also exposed at this layer to allow more sophisticated applications to interact with it directly.
58
59#### Common
60
nmittlerf8314582015-01-27 10:25:39 -080061* [Metadata - headers & trailers](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/Metadata.java)
62* [Status - error code namespace & handling](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/Status.java)
ejonad4531da2014-12-15 10:24:42 -080063
64#### Client
nmittlerf8314582015-01-27 10:25:39 -080065* [Channel - client side binding](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/Channel.java)
66* [Call](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/Call.java)
67* [Client Interceptor](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/ClientInterceptor.java)
ejonad4531da2014-12-15 10:24:42 -080068
69#### Server
nmittlerf8314582015-01-27 10:25:39 -080070* [Server call handler - analog to Channel on server](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/ServerCallHandler.java)
71* [Server Call](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/ServerCall.java)
ejonad4531da2014-12-15 10:24:42 -080072
73
Eric Andersonfb28ad22015-01-29 15:00:58 -080074### Transport
ejonad4531da2014-12-15 10:24:42 -080075
76The 'transport' layer does the heavy lifting of putting & taking bytes off the wire. The interfaces to it are abstract just enough to allow plugging in of different implementations. Transports are modeled as 'Stream' factories. The variation in interface between a server stream and a client stream exists to codify their differing semantics for cancellation and error reporting.
77
78#### Common
79
nmittlerf8314582015-01-27 10:25:39 -080080* [Stream](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/transport/Stream.java)
81* [Stream Listener](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/transport/StreamListener.java)
ejonad4531da2014-12-15 10:24:42 -080082
83#### Client
84
nmittlerf8314582015-01-27 10:25:39 -080085* [Client Stream](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/transport/ClientStream.java)
86* [Client Stream Listener](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/transport/ClientStreamListener.java)
ejonad4531da2014-12-15 10:24:42 -080087
88#### Server
89
nmittlerf8314582015-01-27 10:25:39 -080090* [Server Stream](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/transport/ServerStream.java)
91* [Server Stream Listener](https://github.com/google/grpc-java/blob/master/core/src/main/java/io/grpc/transport/ServerStreamListener.java)
ejonad4531da2014-12-15 10:24:42 -080092
93
Eric Andersonfb28ad22015-01-29 15:00:58 -080094### Examples
ejonad4531da2014-12-15 10:24:42 -080095
nmittlerf8314582015-01-27 10:25:39 -080096Tests showing how these layers are composed to execute calls using protobuf messages can be found here https://github.com/google/grpc-java/tree/master/integration-testing/src/main/java/io/grpc/testing/integration