gRPC

The gRPC has a more complete proposal than MsgPack because it is composed of the data serializer Protobuf, as a layer between communication services making use of RPC.

For serialization, create a .proto file with the information about what will be serialized for RPC communication following a client/server model if needed.

The following code can be seen as an example of a .protocol file, that was extracted from the official site tool:

The greeting service definition:

service Greeter { 

Sends a greeting:

  rpc SayHello (HelloRequest) returns (HelloReply) {} 
} 

The request message containing the user's name:

    message HelloRequest { 
      string name = 1; 
    }  

The response message containing the greetings:

 message HelloReply { string message = 1; ...

Get Microservice Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.