forked from TrueCloudLab/frostfs-api-go
cf765a61a6
Implement gRPC client that can uniformly execute any RPC on the remote server. In the primary implementation, the client is a thin wrapper over gRPC client connection that is required to create the client. In the future, it is planned to expand the library with convenient functionality. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
25 lines
450 B
Go
25 lines
450 B
Go
package grpc
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// CallOption is a messaging session option within RPC.
|
|
type CallOption func(*callParameters)
|
|
|
|
type callParameters struct {
|
|
ctx context.Context
|
|
}
|
|
|
|
func defaultCallParameters() *callParameters {
|
|
return &callParameters{
|
|
ctx: context.Background(),
|
|
}
|
|
}
|
|
|
|
// WithContext returns option to set RPC context.
|
|
func WithContext(ctx context.Context) CallOption {
|
|
return func(prm *callParameters) {
|
|
prm.ctx = ctx
|
|
}
|
|
}
|