Some checks failed
DCO action / DCO (pull_request) Failing after 39s
Tests and linters / Lint (pull_request) Failing after 47s
Tests and linters / Tests (1.19) (pull_request) Successful in 48s
Tests and linters / Tests (1.20) (pull_request) Successful in 49s
Tests and linters / Tests with -race (pull_request) Successful in 1m11s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
30 lines
725 B
Go
30 lines
725 B
Go
package client
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto/encoding"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/credentials"
|
|
)
|
|
|
|
// Client represents client for exchanging messages
|
|
// with a remote server using Protobuf RPC.
|
|
type Client struct {
|
|
cfg
|
|
}
|
|
|
|
// New creates, configures via options and returns new Client instance.
|
|
func New(opts ...Option) *Client {
|
|
var c Client
|
|
c.initDefault()
|
|
|
|
for _, opt := range opts {
|
|
opt(&c.cfg)
|
|
}
|
|
|
|
c.grpcDialOpts = append(c.grpcDialOpts, grpc.WithDefaultCallOptions(grpc.ForceCodec(encoding.ProtoCodec{})))
|
|
if c.tlsCfg != nil {
|
|
c.grpcDialOpts = append(c.grpcDialOpts, grpc.WithTransportCredentials(credentials.NewTLS(c.tlsCfg)))
|
|
}
|
|
|
|
return &c
|
|
}
|