package client import ( "context" "google.golang.org/grpc" ) // CallOption is a messaging session option within Protobuf RPC. type CallOption func(*callParameters) type callParameters struct { ctx context.Context // nolint:containedctx dialer func(context.Context, grpc.ClientConnInterface) error } func defaultCallParameters() *callParameters { return &callParameters{ ctx: context.Background(), } } // WithContext returns option to specify call context. If provided, all network // communications will be based on this context. Otherwise, context.Background() // is used. // // Context SHOULD NOT be nil. func WithContext(ctx context.Context) CallOption { return func(prm *callParameters) { prm.ctx = ctx } } // WithDialer returns option to specify grpc dialer. If passed, it will be // called after the connection is successfully created. func WithDialer(dialer func(context.Context, grpc.ClientConnInterface) error) CallOption { return func(prm *callParameters) { prm.dialer = dialer } }