2021-03-12 12:33:32 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
|
2022-12-09 11:16:24 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/rpc/grpc"
|
2021-03-12 12:33:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
}
|
|
|
|
}
|