frostfs-api-go/rpc/client/client.go
Leonard Lyubich 30c6ca0714 [#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>
2021-03-17 14:03:49 +03:00

29 lines
465 B
Go

package client
import (
"sync"
"github.com/nspcc-dev/neofs-api-go/rpc/grpc"
)
// Client represents client for exchanging messages
// with a remote server using Protobuf RPC.
type Client struct {
*cfg
gRPCClientOnce sync.Once
gRPCClient *grpc.Client
}
// New creates, configures via options and returns new Client instance.
func New(opts ...Option) *Client {
c := defaultCfg()
for _, opt := range opts {
opt(c)
}
return &Client{
cfg: c,
}
}