Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Being easy to use, REST API is the current most popular framework among developers for web application development. REST has been used to expose the services to the outer world, and also for internal communication among internal microservices. However, ease and flexibility come with some pitfalls. REST requires very strict Human Agreement, and relies on Documentation. Also, it has been found not so very performant in the case of internal communication and real-time applications. In 2015, gRPC kicked in. gRPC initially developed at Google is now disrupting the industry. gRPC is a modern open-source high-performance RPC framework, which comes with a simple language-agnostic Interface Definition Language (IDL) system, leveraging Protocol Buffers.
Our machine/machine.proto file should look like this considering Part-1 of this blog series.
As we are leveraging the golang/mock package, to install the package we need to run the following command:
The purpose of this blog is to get you started with gRPC in Go with a simple working example. The blog covers basic information like What, Why, When/Where, and How about the gRPC. We'll majorly focus on the How section, to implement the client and server, to write unittests to test the client and server code separately, and will run the code to establish a client-server communication.
Related posts
- Learning Go and I don't like some features, maybe it's me?
- Google's internal Go style guide
- Robert Griesemer has created a prototype for rewriting anonymous functions to two of the lightweight forms proposed in #21498 and used it to experiment on the Go source.
- Why isn't there a Swagger/OpenAPI for binary formats?
- Go and gRPC is just so intuitive. Here's a detailed full-stack flow with gRPC-Web, Go and React. Also, there is a medium story focused on explaining how such a setup might boost efficiency and the step-by-step implementation.