Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abstractbreazy/grpc-sandbox
An example of Go gRPC-Server with Envoy gRPC-JSON Transcoding.
https://github.com/abstractbreazy/grpc-sandbox
buf envoy golang grpc
Last synced: about 1 month ago
JSON representation
An example of Go gRPC-Server with Envoy gRPC-JSON Transcoding.
- Host: GitHub
- URL: https://github.com/abstractbreazy/grpc-sandbox
- Owner: abstractbreazy
- License: mit
- Created: 2021-09-13T13:58:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-25T20:13:43.000Z (over 2 years ago)
- Last Synced: 2024-11-16T03:41:45.829Z (3 months ago)
- Topics: buf, envoy, golang, grpc
- Language: Go
- Homepage:
- Size: 102 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## gRPC-JSON Transcoder
[![Go Report Card](https://goreportcard.com/badge/github.com/abstractbreazy/grpc-sandbox)](https://goreportcard.com/report/github.com/abstractbreazy/grpc-sandbox)
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.
```shell
make
```I recommend completing [Tour of Buf](https://docs.buf.build/tour/introduction) to understand the functionality of both the CLI and the BSR.
### *Envoy*
Envoy is a very flexible proxy. It's implements *gRPC-JSON transcoding* as a [filter](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/grpc_stats_filter).
In order to to start transcoding you need to:- Generate the proto descriptor of gRPC service
```bash
make image-gen
```
- Run Envoy using [Docker](https://docs.docker.com/get-docker/)
```bash
make docker-run
```
- Build a gRPC-service:
```bash
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:
``` bash
curl -X 'GET' \
'http://localhost:8080/v1/example/ping' \
-H 'accept: application/json'
```### *gRPCurl*
You can use [gRPCurl](https://github.com/fullstorydev/grpcurl) to interact with gRPC server without using an Envoy proxy.
Example of gRPCurl usage:
```bash
grpcurl \
-plaintext \
localhost:9092
describegrpcurl \
-plaintext \
-d '{}' \
localhost:9092 \
example.v1.Example.Ping
```### *Tests*
You can use `make` command to run unit-tests without running the app or building `envoy` container:
```bash
make go-test
```### *Links*:
- [Envoy gRPC-JSON transcoder](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/grpc_json_transcoder_filter)
- [gRPCurl Library](https://github.com/fullstorydev/grpcurl)
- [Buf.build documantation](https://docs.buf.build/introduction)
- [GNU Make](https://www.gnu.org/software/make/)
- [Docker](https://docs.docker.com/get-docker/)