Junior — Middle
Can you list the main types of gRPC calls?
sobes.tech AI
Answer from AI
In gRPC, there are four main types of calls (RPC):
- Unary RPC — the client sends a single request and receives a single response.
- Server Streaming RPC — the client sends a single request, and the server returns a stream of responses.
- Client Streaming RPC — the client sends a stream of requests, and the server returns a single response.
- Bidirectional Streaming RPC — both the client and server exchange streams of messages simultaneously.
Example of a unary call in Go:
resp, err := client.SomeMethod(ctx, &pb.Request{Data: "example"})
if err != nil {
log.Fatalf("Error calling SomeMethod: %v", err)
}
fmt.Println("Response:", resp.Result)