[#263] Implement client for exchanging raw Protobuf messages
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>
This commit is contained in:
parent
c61656a43f
commit
30c6ca0714
6 changed files with 364 additions and 0 deletions
27
rpc/client/call_options.go
Normal file
27
rpc/client/call_options.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
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))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue