gRPC

gRPC is a open-source RPC framework developed by Google. It uses Protocol Buffers for serializing structured data.

Example of interface definition in Protocal Buffers:

// The greeter 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;
}

It resembles typical type definitions in programming languages, except using message for data classes, and rpc for functions.

Have you noticed the numbers? This is the tricky part of Protocol Buffers.

In Protocol Buffers, numbers are used to uniquely identify fields within a message definition. Each field is assigned a unique integer number. This number is used to encode and decode the field's value in the serialized message representation.

Why? It's more efficient for encoding and maximizes compatibility with different client versions.