30c6ca0714
Implement generic `Client` that can communicate with the remote server via protobuf `Message`'s. The client can uniformly execute any protobuf RPC on the remote server using any of the supported transport protocols. Currently only gRPC protocol is supported. Additionally implement helpful functions to transmit messages by one of the flow types: unary, client- or server-side stream. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
27 lines
579 B
Go
27 lines
579 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/rpc/grpc"
|
|
)
|
|
|
|
// CallOption is a messaging session option within Protobuf RPC.
|
|
type CallOption func(*callParameters)
|
|
|
|
type callParameters struct {
|
|
callOpts []grpc.CallOption
|
|
}
|
|
|
|
func defaultCallParameters() *callParameters {
|
|
return &callParameters{
|
|
callOpts: make([]grpc.CallOption, 0, 1),
|
|
}
|
|
}
|
|
|
|
// WithContext return options to specify call context.
|
|
func WithContext(ctx context.Context) CallOption {
|
|
return func(prm *callParameters) {
|
|
prm.callOpts = append(prm.callOpts, grpc.WithContext(ctx))
|
|
}
|
|
}
|