forked from TrueCloudLab/frostfs-sdk-go
[#276] Merge repo with frostfs-api-go
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
parent
5361f0eceb
commit
6ce73790ea
337 changed files with 66666 additions and 283 deletions
40
api/rpc/client/call_options.go
Normal file
40
api/rpc/client/call_options.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue