gRPC Ecosystem with GO
In this story, we will talk about some of the projects that are not part of the core gRPC implementation but that are pretty useful.
These projects are built around gRPC to overcome problems or limitations encountered while building a production system using gRPC. For example, we will check projects that let us match restful with gRPC easily.
This story is a brief of one part of gRPC up & Running book and I highly recommend to read this book for persons that want to complete their knowledge about modern inter-process communication in microservices architect.
you can follow my sample code in GitHub to clear some explanations.
1 I want to talk about gRPC Gateway, The gRPC gateway plug-in enables the protocol buffer compiler to read the gRPC service definition and generate a reverse proxy server, which translates a RESTful JSON API into gRPC.
instead of building a gRPC client, we will build a reverse proxy service, which exposes RESTful API for each remote method in the gRPC service and accepts HTTP requests from REST clients. Once it receives an HTTP request, it translates the request into a gRPC message and calls the remote method in the backend service. The response message from the backend server again converts back to an HTTP response.
in Google API Documentation you can find all rules that we must follow them on developing.
The gRPC gateway is only supported in Go, which means we cannot compile and generate a reverse proxy service for the gRPC gateway in other languages.
2 HTTP/JSON Transcoding for gRPC; Transcoding is the process of translating HTTP JSON calls to RPC calls and passing them to the gRPC service. This is useful when the client applications don’t have support for gRPC and need to provide access to talk to the gRPC service via JSON over HTTP. ( Istio, Google cloud endpoint, Envoy Proxy)
3 The gRPC Server Reflection Protocol; Server reflection is a service defined on a gRPC server that provides information about publicly accessible gRPC services on that server. In simple terms, server reflection provides service definitions of the services registered on a server to the client application. So the client doesn’t need precompiled service definitions to communicate with the services.
One of the advantages of reflection protocol is, After enabling server reflection in your server application, you can use the gRPC CLI tool to check your server.
4 gRPC Middleware or Interceptor; In basic terms, the middleware is a software component in a distributed system that is used to connect different components to route requests generated by the client to the backend server. In gRPC Middleware, we are also talking about running code before and after the gRPC server or client application.
5 Health Checking Protocol; gRPC defines a health checking protocol (Health Checking API) that allows the gRPC services to expose the server status so that the consumers can probe the server’s health information.
Please pay attention that there is a big difference between Health Checking Protocol/gRPC Health Probe and Health check on Route53/LB/ASG in AWS.
6 protoc-gen-star (PG*); is a protoc plugin library for efficient proto-based code generation, but when I am writing this story, the plugin is in-progress status and I hope sooner we visit productive version.
7 protoc-gen-validate (PGV); PGV is a protoc plugin to generate polyglot message validators. While protocol buffers effectively guarantee the types of structured data, they cannot enforce semantic rules for values. This plugin adds support to protoc-generated code to validate such constraints.