I am learning about protobuf and gRPC in Go. Upon generating pb.go file with
protoc --go_out=plugins=grpc:chat chat.proto
for the file chat.proto
syntax = "proto3";
package chat;
message Message {
string body = 1;
}
service ChatService {
rpc SayHello(Message) returns (Message) {}
}
The generated chat.pb.go
has these 2 interfaces:
type ChatServiceClient interface {
SayHello(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error)
}
...
type ChatServiceServer interface {
SayHello(context.Context, *Message) (*Message, error)
}
I am confused with the use of named parameters in ChatServiceClient
interface. Is there any use of these parameters: ctx
, in
and opts
. When should we have named vs unnamed parameters in such a case?