github.com/TrueCloudLab/frostfs-api-go/v2@v2.0.0-20230228134343-196241c4e79a/rpc/client/call_options.go (about) 1 package client 2 3 import ( 4 "context" 5 ) 6 7 // CallOption is a messaging session option within Protobuf RPC. 8 type CallOption func(*callParameters) 9 10 type callParameters struct { 11 ctx context.Context 12 } 13 14 func defaultCallParameters() *callParameters { 15 return &callParameters{ 16 ctx: context.Background(), 17 } 18 } 19 20 // WithContext returns option to specify call context. If provided, all network 21 // communications will be based on this context. Otherwise, context.Background() 22 // is used. 23 // 24 // Context SHOULD NOT be nil. 25 func WithContext(ctx context.Context) CallOption { 26 return func(prm *callParameters) { 27 prm.ctx = ctx 28 } 29 }