Protobuf, gRPC, Envoy example using
buf.build
tool.
If you have Go
, make
and buf.build
tool installed, you should be able to just execute.
make
I recommend completing Tour of Buf to understand the functionality of both the CLI and the BSR.
Envoy is a very flexible proxy. It's implements gRPC-JSON transcoding as a filter. In order to to start transcoding you need to:
- Generate the proto descriptor of gRPC service
make image-gen
- Run Envoy using Docker
make docker-run
- Build a gRPC-service:
make run
By default, when transcoding occurs, gRPC-JSON encodes the message output of a gRPC service method into JSON and sets the HTTP response Content-Type header to application/json
.
You can verify that gRPC-JSON transcoding works fine by sending the following request:
curl -X 'GET' \
'http://localhost:8080/v1/example/ping' \
-H 'accept: application/json'
You can use gRPCurl to interact with gRPC server without using an Envoy proxy.
Example of gRPCurl usage:
grpcurl \
-plaintext \
localhost:9092
describe
grpcurl \
-plaintext \
-d '{}' \
localhost:9092 \
example.v1.Example.Ping
You can use make
command to run unit-tests without running the app or building envoy
container:
make go-test