forked from TrueCloudLab/frostfs-api-go
[#117] rpc: Allow to specify custom gRPC dialer
After grpc upgrade there is no DialContext call. So connection is not actually established after created. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
c9782cf3ef
commit
13fa0da374
4 changed files with 26 additions and 10 deletions
|
@ -2,13 +2,16 @@ 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
|
||||
ctx context.Context // nolint:containedctx
|
||||
dialer func(context.Context, grpc.ClientConnInterface) error
|
||||
}
|
||||
|
||||
func defaultCallParameters() *callParameters {
|
||||
|
@ -27,3 +30,11 @@ func WithContext(ctx context.Context) CallOption {
|
|||
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