0
votes

When I read the source code about grpc-go such as rsp, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: name}) in grpc helloworld example. I know it use protobuf message to send request and receive response, and it also use protobuf transmit error message defined in status.proto file. But I can't understand how context transmit between client and server. I guess it also use pb message but I can't find where it's defined. Or it is transimit by http2 header frame?

2

2 Answers

0
votes

It's not clear what do you mean by context transmission, because context.Context is just a Go object that has no methods for serialization / deserialization. Perhaps you're talking about GRPC metadata. As far as I remember, they use HTTP headers as a transport.

0
votes

Cassia,

The context passed as first argument by the client is not the same received by the server.

Both of them are just local context handlers. They help your local code to check if the request is still running. So you may interrupt a process it the request is interrupted for some reason.