Package list golang-github-go-kit-kit / 9fc9672
made wraps more readable in transport/grpc readme David Sudia 4 years ago
1 changed file(s) with 14 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
00 # grpc
11
22 [gRPC](http://www.grpc.io/) is an excellent, modern IDL and transport for
3 microservices.
4 If you're starting a greenfield project, go-kit strongly recommends gRPC as
5 your default transport.
3 microservices. If you're starting a greenfield project, go-kit strongly
4 recommends gRPC as your default transport.
65
76 One important note is that while gRPC supports streaming requests and replies,
87 go-kit does not. You can still use streams in your service, but their
109
1110 Using gRPC and go-kit together is very simple.
1211
13 First, define your service using protobuf3.
14 This is explained [in gRPC documentation](http://www.grpc.io/docs/#defining-a-service).
12 First, define your service using protobuf3. This is explained
13 [in gRPC documentation](http://www.grpc.io/docs/#defining-a-service).
1514 See
1615 [add.proto](https://github.com/go-kit/kit/blob/ec8b02591ee873433565a1ae9d317353412d1d27/examples/addsvc/pb/add.proto)
17 for an example.
18 Make sure the proto definition matches your service's go-kit (interface) definition.
16 for an example. Make sure the proto definition matches your service's go-kit
17 (interface) definition.
1918
2019 Next, get the protoc compiler.
2120
2221 You can download pre-compiled binaries from the
2322 [protobuf release page](https://github.com/google/protobuf/releases).
24 You will unzip a folder called `protoc3` with a subdirectory `bin` containing an executable.
25 Move that executable somewhere in your `$PATH` and you're good to go!
23 You will unzip a folder called `protoc3` with a subdirectory `bin` containing
24 an executable. Move that executable somewhere in your `$PATH` and you're good
25 to go!
2626
2727 It can also be built from source.
2828
3939 protoc add.proto --go_out=plugins=grpc:.
4040 ```
4141
42 Finally, write a tiny binding from your service definition to the gRPC definition.
43 It's a simple conversion from one domain to another.
42 Finally, write a tiny binding from your service definition to the gRPC
43 definition. It's a simple conversion from one domain to another.
4444 See
4545 [grpc_binding.go](https://github.com/go-kit/kit/blob/ec8b02591ee873433565a1ae9d317353412d1d27/examples/addsvc/grpc_binding.go)
4646 for an example.
4848 That's it!
4949 The gRPC binding can be bound to a listener and serve normal gRPC requests.
5050 And within your service, you can use standard go-kit components and idioms.
51 See [addsvc](https://github.com/go-kit/kit/tree/master/examples/addsvc) for a complete
52 working example with gRPC support.
53 And remember: go-kit services can support multiple transports simultaneously.
51 See [addsvc](https://github.com/go-kit/kit/tree/master/examples/addsvc) for
52 a complete working example with gRPC support. And remember: go-kit services
53 can support multiple transports simultaneously.