Sobes.tech
Junior — Middle

Kas saaksite selgitada gRPC tööpõhimõtet ja selle peamisi omadusi?

sobes.tech AI

Vastus AI-lt

gRPC is a modern framework for remote procedure calls (RPC), developed by Google. It operates over HTTP/2, providing efficient bidirectional communication, stream multiplexing, and header compression.

Key features of gRPC:

  • Uses Protocol Buffers (protobuf) for describing services and serializing data — a compact and fast format.
  • Supports various call types: unary (one request — one response), server streaming, client streaming, and bidirectional streaming.
  • Provides a strictly typed contract between client and server.
  • Easily generates code in different programming languages.

Example of a simple gRPC service in Go:

// Service definition in protobuf
syntax = "proto3";

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

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
}

After code generation, the server and client can be easily implemented using the generated interfaces.