2021-03-12 12:33:32 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CallOption is a messaging session option within Protobuf RPC.
|
|
|
|
type CallOption func(*callParameters)
|
|
|
|
|
|
|
|
type callParameters struct {
|
2023-05-03 11:04:03 +00:00
|
|
|
ctx context.Context // nolint:containedctx
|
2021-03-12 12:33:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func defaultCallParameters() *callParameters {
|
|
|
|
return &callParameters{
|
2022-10-03 09:34:22 +00:00
|
|
|
ctx: context.Background(),
|
2021-03-12 12:33:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-03 09:34:22 +00:00
|
|
|
// 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.
|
2021-03-12 12:33:32 +00:00
|
|
|
func WithContext(ctx context.Context) CallOption {
|
|
|
|
return func(prm *callParameters) {
|
2022-10-03 09:34:22 +00:00
|
|
|
prm.ctx = ctx
|
2021-03-12 12:33:32 +00:00
|
|
|
}
|
|
|
|
}
|