I have defined a client and server. They all have a ctx(context) as parameter,client and server communicate by grpc.
type Client interface {
GetFileVersion(ctx context.Context, in *Req) (*Resp, error)
}
type client struct {
cc *grpc.ClientConn
}
func (c *client) GetFileVersion(ctx context.Context, in *Req) (*Resp, error) {
out := new(Resp)
err := grpc.Invoke(ctx, "/testpb/GetFileVersion", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
type Server interface {
GetFileVersion(context.Context, *Req) (*Resp, error)
}
If I set value in ctx in the implement of GetFileVersion in client,can I get this value in server?
ctx = context.WithValue(parent, "test", 123)