client: Make PrmDial
, PrmInit
fields public and make setters deprecated #193
21 changed files with 106 additions and 91 deletions
|
@ -79,7 +79,7 @@ func (c *Client) BalanceGet(ctx context.Context, prm PrmBalanceGet) (*ResBalance
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,31 +78,22 @@ func (c *Client) Init(prm PrmInit) {
|
||||||
//
|
//
|
||||||
// See also Init / Close.
|
// See also Init / Close.
|
||||||
func (c *Client) Dial(ctx context.Context, prm PrmDial) error {
|
func (c *Client) Dial(ctx context.Context, prm PrmDial) error {
|
||||||
if prm.endpoint == "" {
|
if prm.Endpoint == "" {
|
||||||
return errorServerAddrUnset
|
return errorServerAddrUnset
|
||||||
}
|
}
|
||||||
|
|
||||||
if prm.timeoutDialSet {
|
if prm.DialTimeout <= 0 {
|
||||||
if prm.timeoutDial <= 0 {
|
prm.DialTimeout = defaultDialTimeout
|
||||||
return errorNonPositiveTimeout
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
prm.timeoutDial = 5 * time.Second
|
|
||||||
}
|
}
|
||||||
|
if prm.StreamTimeout <= 0 {
|
||||||
if prm.streamTimeoutSet {
|
prm.StreamTimeout = defaultStreamTimeout
|
||||||
if prm.streamTimeout <= 0 {
|
|
||||||
return errorNonPositiveTimeout
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
prm.streamTimeout = 10 * time.Second
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.c = *client.New(append(
|
c.c = *client.New(append(
|
||||||
client.WithNetworkURIAddress(prm.endpoint, prm.tlsConfig),
|
client.WithNetworkURIAddress(prm.Endpoint, prm.TLSConfig),
|
||||||
client.WithDialTimeout(prm.timeoutDial),
|
client.WithDialTimeout(prm.DialTimeout),
|
||||||
client.WithRWTimeout(prm.streamTimeout),
|
client.WithRWTimeout(prm.StreamTimeout),
|
||||||
client.WithGRPCDialOptions(prm.dialOptions),
|
client.WithGRPCDialOptions(prm.GRPCDialOptions),
|
||||||
)...)
|
)...)
|
||||||
|
|
||||||
c.setFrostFSAPIServer((*coreServer)(&c.c))
|
c.setFrostFSAPIServer((*coreServer)(&c.c))
|
||||||
|
@ -144,21 +135,23 @@ func (c *Client) Close() error {
|
||||||
//
|
//
|
||||||
// See also Init.
|
// See also Init.
|
||||||
type PrmInit struct {
|
type PrmInit struct {
|
||||||
disableFrostFSErrorResolution bool
|
DisableFrostFSErrorResolution bool
|
||||||
|
|
||||||
key ecdsa.PrivateKey
|
Key ecdsa.PrivateKey
|
||||||
|
|
||||||
cbRespInfo func(ResponseMetaInfo) error
|
ResponseInfoCallback func(ResponseMetaInfo) error
|
||||||
|
|
||||||
netMagic uint64
|
NetMagic uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaultPrivateKey sets Client private key to be used for the protocol
|
// SetDefaultPrivateKey sets Client private key to be used for the protocol
|
||||||
// communication by default.
|
// communication by default.
|
||||||
//
|
//
|
||||||
// Required for operations without custom key parametrization (see corresponding Prm* docs).
|
// Required for operations without custom key parametrization (see corresponding Prm* docs).
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmInit.Key instead.
|
||||||
func (x *PrmInit) SetDefaultPrivateKey(key ecdsa.PrivateKey) {
|
func (x *PrmInit) SetDefaultPrivateKey(key ecdsa.PrivateKey) {
|
||||||
x.key = key
|
x.Key = key
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: method is no-op. Option is default.
|
// Deprecated: method is no-op. Option is default.
|
||||||
|
@ -169,31 +162,40 @@ func (x *PrmInit) ResolveFrostFSFailures() {
|
||||||
// FrostFS protocol only in resulting structure (see corresponding Res* docs).
|
// FrostFS protocol only in resulting structure (see corresponding Res* docs).
|
||||||
// These errors are returned from each protocol operation. By default, statuses
|
// These errors are returned from each protocol operation. By default, statuses
|
||||||
// are resolved and returned as a Go built-in errors.
|
// are resolved and returned as a Go built-in errors.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmInit.DisableFrostFSErrorResolution instead.
|
||||||
func (x *PrmInit) DisableFrostFSFailuresResolution() {
|
func (x *PrmInit) DisableFrostFSFailuresResolution() {
|
||||||
x.disableFrostFSErrorResolution = true
|
x.DisableFrostFSErrorResolution = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetResponseInfoCallback makes the Client to pass ResponseMetaInfo from each
|
// SetResponseInfoCallback makes the Client to pass ResponseMetaInfo from each
|
||||||
// FrostFS server response to f. Nil (default) means ignore response meta info.
|
// FrostFS server response to f. Nil (default) means ignore response meta info.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmInit.ResponseInfoCallback instead.
|
||||||
func (x *PrmInit) SetResponseInfoCallback(f func(ResponseMetaInfo) error) {
|
func (x *PrmInit) SetResponseInfoCallback(f func(ResponseMetaInfo) error) {
|
||||||
x.cbRespInfo = f
|
x.ResponseInfoCallback = f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultDialTimeout = 5 * time.Second
|
||||||
|
defaultStreamTimeout = 10 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
// PrmDial groups connection parameters for the Client.
|
// PrmDial groups connection parameters for the Client.
|
||||||
//
|
//
|
||||||
// See also Dial.
|
// See also Dial.
|
||||||
type PrmDial struct {
|
type PrmDial struct {
|
||||||
endpoint string
|
Endpoint string
|
||||||
|
|
||||||
tlsConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
|
|
||||||
timeoutDialSet bool
|
// If DialTimeout is non-positive, then it's set to defaultDialTimeout.
|
||||||
timeoutDial time.Duration
|
DialTimeout time.Duration
|
||||||
|
|
||||||
streamTimeoutSet bool
|
// If StreamTimeout is non-positive, then it's set to defaultStreamTimeout.
|
||||||
streamTimeout time.Duration
|
StreamTimeout time.Duration
|
||||||
|
|
||||||
dialOptions []grpc.DialOption
|
GRPCDialOptions []grpc.DialOption
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetServerURI sets server URI in the FrostFS network.
|
// SetServerURI sets server URI in the FrostFS network.
|
||||||
|
@ -209,33 +211,41 @@ type PrmDial struct {
|
||||||
// grpcs
|
// grpcs
|
||||||
//
|
//
|
||||||
// See also SetTLSConfig.
|
// See also SetTLSConfig.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmDial.Endpoint instead.
|
||||||
func (x *PrmDial) SetServerURI(endpoint string) {
|
func (x *PrmDial) SetServerURI(endpoint string) {
|
||||||
x.endpoint = endpoint
|
x.Endpoint = endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTLSConfig sets tls.Config to open TLS client connection
|
// SetTLSConfig sets tls.Config to open TLS client connection
|
||||||
// to the FrostFS server. Nil (default) means insecure connection.
|
// to the FrostFS server. Nil (default) means insecure connection.
|
||||||
//
|
//
|
||||||
// See also SetServerURI.
|
// See also SetServerURI.
|
||||||
|
//
|
||||||
|
// Depreacted: Use PrmDial.TLSConfig instead.
|
||||||
func (x *PrmDial) SetTLSConfig(tlsConfig *tls.Config) {
|
func (x *PrmDial) SetTLSConfig(tlsConfig *tls.Config) {
|
||||||
x.tlsConfig = tlsConfig
|
x.TLSConfig = tlsConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTimeout sets the timeout for connection to be established.
|
// SetTimeout sets the timeout for connection to be established.
|
||||||
// MUST BE positive. If not called, 5s timeout will be used by default.
|
// MUST BE positive. If not called, 5s timeout will be used by default.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmDial.DialTimeout instead.
|
||||||
func (x *PrmDial) SetTimeout(timeout time.Duration) {
|
func (x *PrmDial) SetTimeout(timeout time.Duration) {
|
||||||
x.timeoutDialSet = true
|
x.DialTimeout = timeout
|
||||||
x.timeoutDial = timeout
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetStreamTimeout sets the timeout for individual operations in streaming RPC.
|
// SetStreamTimeout sets the timeout for individual operations in streaming RPC.
|
||||||
// MUST BE positive. If not called, 10s timeout will be used by default.
|
// MUST BE positive. If not called, 10s timeout will be used by default.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmDial.StreamTimeout instead.
|
||||||
func (x *PrmDial) SetStreamTimeout(timeout time.Duration) {
|
func (x *PrmDial) SetStreamTimeout(timeout time.Duration) {
|
||||||
x.streamTimeoutSet = true
|
x.StreamTimeout = timeout
|
||||||
x.streamTimeout = timeout
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetGRPCDialOptions sets the gRPC dial options for new gRPC client connection.
|
// SetGRPCDialOptions sets the gRPC dial options for new gRPC client connection.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmDial.GRPCDialOptions instead.
|
||||||
func (x *PrmDial) SetGRPCDialOptions(opts ...grpc.DialOption) {
|
func (x *PrmDial) SetGRPCDialOptions(opts ...grpc.DialOption) {
|
||||||
x.dialOptions = opts
|
x.GRPCDialOptions = opts
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,9 @@ func assertStatusErr(tb testing.TB, res interface{ Status() apistatus.Status })
|
||||||
}
|
}
|
||||||
|
|
||||||
func newClient(server frostFSAPIServer) *Client {
|
func newClient(server frostFSAPIServer) *Client {
|
||||||
var prm PrmInit
|
prm := PrmInit{
|
||||||
prm.SetDefaultPrivateKey(*key)
|
Key: *key,
|
||||||
|
}
|
||||||
|
|
||||||
var c Client
|
var c Client
|
||||||
c.Init(prm)
|
c.Init(prm)
|
||||||
|
@ -43,8 +44,9 @@ func TestClient_DialContext(t *testing.T) {
|
||||||
var c Client
|
var c Client
|
||||||
|
|
||||||
// try to connect to any host
|
// try to connect to any host
|
||||||
var prm PrmDial
|
prm := PrmDial{
|
||||||
prm.SetServerURI("localhost:8080")
|
Endpoint: "localhost:8080",
|
||||||
|
}
|
||||||
|
|
||||||
assert := func(ctx context.Context, errExpected error) {
|
assert := func(ctx context.Context, errExpected error) {
|
||||||
// expect particular context error according to Dial docs
|
// expect particular context error according to Dial docs
|
||||||
|
|
|
@ -50,7 +50,6 @@ var (
|
||||||
errorMissingObject = errors.New("missing object")
|
errorMissingObject = errors.New("missing object")
|
||||||
errorAccountNotSet = errors.New("account not set")
|
errorAccountNotSet = errors.New("account not set")
|
||||||
errorServerAddrUnset = errors.New("server address is unset or empty")
|
errorServerAddrUnset = errors.New("server address is unset or empty")
|
||||||
errorNonPositiveTimeout = errors.New("non-positive timeout")
|
|
||||||
errorEACLTableNotSet = errors.New("eACL table not set")
|
errorEACLTableNotSet = errors.New("eACL table not set")
|
||||||
errorMissingAnnouncements = errors.New("missing announcements")
|
errorMissingAnnouncements = errors.New("missing announcements")
|
||||||
errorZeroRangeLength = errors.New("zero range length")
|
errorZeroRangeLength = errors.New("zero range length")
|
||||||
|
@ -78,19 +77,19 @@ func (c *Client) prepareRequest(req request, meta *v2session.RequestMetaHeader)
|
||||||
|
|
||||||
meta.SetTTL(ttl)
|
meta.SetTTL(ttl)
|
||||||
meta.SetVersion(verV2)
|
meta.SetVersion(verV2)
|
||||||
meta.SetNetworkMagic(c.prm.netMagic)
|
meta.SetNetworkMagic(c.prm.NetMagic)
|
||||||
|
|
||||||
req.SetMetaHeader(meta)
|
req.SetMetaHeader(meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
// processResponse verifies response signature and converts status to an error if needed.
|
// processResponse verifies response signature and converts status to an error if needed.
|
||||||
func (c *Client) processResponse(resp responseV2) (apistatus.Status, error) {
|
func (c *Client) processResponse(resp responseV2) (apistatus.Status, error) {
|
||||||
if c.prm.cbRespInfo != nil {
|
if c.prm.ResponseInfoCallback != nil {
|
||||||
rmi := ResponseMetaInfo{
|
rmi := ResponseMetaInfo{
|
||||||
key: resp.GetVerificationHeader().GetBodySignature().GetKey(),
|
key: resp.GetVerificationHeader().GetBodySignature().GetKey(),
|
||||||
epoch: resp.GetMetaHeader().GetEpoch(),
|
epoch: resp.GetMetaHeader().GetEpoch(),
|
||||||
}
|
}
|
||||||
if err := c.prm.cbRespInfo(rmi); err != nil {
|
if err := c.prm.ResponseInfoCallback(rmi); err != nil {
|
||||||
return nil, fmt.Errorf("response callback error: %w", err)
|
return nil, fmt.Errorf("response callback error: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +100,7 @@ func (c *Client) processResponse(resp responseV2) (apistatus.Status, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
st := apistatus.FromStatusV2(resp.GetMetaHeader().GetStatus())
|
st := apistatus.FromStatusV2(resp.GetMetaHeader().GetStatus())
|
||||||
if !c.prm.disableFrostFSErrorResolution {
|
if !c.prm.DisableFrostFSErrorResolution {
|
||||||
return st, apistatus.ErrFromStatus(st)
|
return st, apistatus.ErrFromStatus(st)
|
||||||
}
|
}
|
||||||
return st, nil
|
return st, nil
|
||||||
|
|
|
@ -52,7 +52,7 @@ func (prm *PrmContainerDelete) buildRequest(c *Client) (*v2container.DeleteReque
|
||||||
|
|
||||||
var sig frostfscrypto.Signature
|
var sig frostfscrypto.Signature
|
||||||
|
|
||||||
err := sig.Calculate(frostfsecdsa.SignerRFC6979(c.prm.key), data)
|
err := sig.Calculate(frostfsecdsa.SignerRFC6979(c.prm.Key), data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("calculate signature: %w", err)
|
return nil, fmt.Errorf("calculate signature: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ func (c *Client) ContainerDelete(ctx context.Context, prm PrmContainerDelete) (*
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ func (c *Client) ContainerEACL(ctx context.Context, prm PrmContainerEACL) (*ResC
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ func (c *Client) ContainerGet(ctx context.Context, prm PrmContainerGet) (*ResCon
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (c *Client) ContainerList(ctx context.Context, prm PrmContainerList) (*ResC
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ func (x *PrmContainerPut) buildRequest(c *Client) (*v2container.PutRequest, erro
|
||||||
|
|
||||||
var sig frostfscrypto.Signature
|
var sig frostfscrypto.Signature
|
||||||
|
|
||||||
err := container.CalculateSignature(&sig, *x.Container, c.prm.key)
|
err := container.CalculateSignature(&sig, *x.Container, c.prm.Key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("calculate container signature: %w", err)
|
return nil, fmt.Errorf("calculate container signature: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ func (c *Client) ContainerPut(ctx context.Context, prm PrmContainerPut) (*ResCon
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ func (x *PrmContainerSetEACL) buildRequest(c *Client) (*v2container.SetExtendedA
|
||||||
|
|
||||||
var sig frostfscrypto.Signature
|
var sig frostfscrypto.Signature
|
||||||
|
|
||||||
err := sig.Calculate(frostfsecdsa.SignerRFC6979(c.prm.key), eaclV2.StableMarshal(nil))
|
err := sig.Calculate(frostfsecdsa.SignerRFC6979(c.prm.Key), eaclV2.StableMarshal(nil))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("calculate signature: %w", err)
|
return nil, fmt.Errorf("calculate signature: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func (c *Client) ContainerSetEACL(ctx context.Context, prm PrmContainerSetEACL)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, prm PrmAnnounce
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ func (c *Client) EndpointInfo(ctx context.Context, prm PrmEndpointInfo) (*ResEnd
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ func (c *Client) NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (*ResNetwo
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ func (c *Client) NetMapSnapshot(ctx context.Context, _ PrmNetMapSnapshot) (*ResN
|
||||||
req.SetBody(&body)
|
req.SetBody(&body)
|
||||||
c.prepareRequest(&req, &meta)
|
c.prepareRequest(&req, &meta)
|
||||||
|
|
||||||
err := signature.SignServiceMessage(&c.prm.key, &req)
|
err := signature.SignServiceMessage(&c.prm.Key, &req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ func (c *Client) ObjectDelete(ctx context.Context, prm PrmObjectDelete) (*ResObj
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
key := c.prm.key
|
key := c.prm.Key
|
||||||
if prm.Key != nil {
|
if prm.Key != nil {
|
||||||
key = *prm.Key
|
key = *prm.Key
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,7 +307,7 @@ func (c *Client) ObjectGetInit(ctx context.Context, prm PrmObjectGet) (*ObjectRe
|
||||||
|
|
||||||
key := prm.Key
|
key := prm.Key
|
||||||
if key == nil {
|
if key == nil {
|
||||||
key = &c.prm.key
|
key = &c.prm.Key
|
||||||
}
|
}
|
||||||
|
|
||||||
err = signature.SignServiceMessage(key, req)
|
err = signature.SignServiceMessage(key, req)
|
||||||
|
@ -468,7 +468,7 @@ func (c *Client) ObjectHead(ctx context.Context, prm PrmObjectHead) (*ResObjectH
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
key := c.prm.key
|
key := c.prm.Key
|
||||||
if prm.Key != nil {
|
if prm.Key != nil {
|
||||||
key = *prm.Key
|
key = *prm.Key
|
||||||
}
|
}
|
||||||
|
@ -776,7 +776,7 @@ func (c *Client) ObjectRangeInit(ctx context.Context, prm PrmObjectRange) (*Obje
|
||||||
|
|
||||||
key := prm.Key
|
key := prm.Key
|
||||||
if key == nil {
|
if key == nil {
|
||||||
key = &c.prm.key
|
key = &c.prm.Key
|
||||||
}
|
}
|
||||||
|
|
||||||
err = signature.SignServiceMessage(key, req)
|
err = signature.SignServiceMessage(key, req)
|
||||||
|
|
|
@ -172,7 +172,7 @@ func (c *Client) ObjectHash(ctx context.Context, prm PrmObjectHash) (*ResObjectH
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
key := c.prm.key
|
key := c.prm.Key
|
||||||
if prm.Key != nil {
|
if prm.Key != nil {
|
||||||
key = *prm.Key
|
key = *prm.Key
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func (c *Client) objectPutInitRaw(ctx context.Context, prm PrmObjectPutInit) (*o
|
||||||
return nil, fmt.Errorf("open stream: %w", err)
|
return nil, fmt.Errorf("open stream: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.key = &c.prm.key
|
w.key = &c.prm.Key
|
||||||
if prm.Key != nil {
|
if prm.Key != nil {
|
||||||
w.key = prm.Key
|
w.key = prm.Key
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ func (c *Client) ObjectPutSingle(ctx context.Context, prm PrmObjectPutSingle) (*
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
key := &c.prm.key
|
key := &c.prm.Key
|
||||||
if prm.Key != nil {
|
if prm.Key != nil {
|
||||||
key = prm.Key
|
key = prm.Key
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ func (c *Client) objectPutInitTransformer(prm PrmObjectPutInit) (*objectWriterTr
|
||||||
client: c,
|
client: c,
|
||||||
prm: prm,
|
prm: prm,
|
||||||
}
|
}
|
||||||
key := &c.prm.key
|
key := &c.prm.Key
|
||||||
if prm.Key != nil {
|
if prm.Key != nil {
|
||||||
key = prm.Key
|
key = prm.Key
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ func (it *internalTarget) putAsStream(ctx context.Context, o *object.Object) err
|
||||||
wrt.WritePayloadChunk(ctx, o.Payload())
|
wrt.WritePayloadChunk(ctx, o.Payload())
|
||||||
}
|
}
|
||||||
it.res, err = wrt.Close(ctx)
|
it.res, err = wrt.Close(ctx)
|
||||||
if err == nil && it.client.prm.disableFrostFSErrorResolution && !apistatus.IsSuccessful(it.res.st) {
|
if err == nil && it.client.prm.DisableFrostFSErrorResolution && !apistatus.IsSuccessful(it.res.st) {
|
||||||
err = apistatus.ErrFromStatus(it.res.st)
|
err = apistatus.ErrFromStatus(it.res.st)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -115,7 +115,7 @@ func (it *internalTarget) tryPutSingle(ctx context.Context, o *object.Object) (b
|
||||||
statusRes: res.statusRes,
|
statusRes: res.statusRes,
|
||||||
obj: id,
|
obj: id,
|
||||||
}
|
}
|
||||||
if it.client.prm.disableFrostFSErrorResolution && !apistatus.IsSuccessful(it.res.st) {
|
if it.client.prm.DisableFrostFSErrorResolution && !apistatus.IsSuccessful(it.res.st) {
|
||||||
return true, apistatus.ErrFromStatus(it.res.st)
|
return true, apistatus.ErrFromStatus(it.res.st)
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|
|
@ -284,7 +284,7 @@ func (c *Client) ObjectSearchInit(ctx context.Context, prm PrmObjectSearch) (*Ob
|
||||||
|
|
||||||
key := prm.Key
|
key := prm.Key
|
||||||
if key == nil {
|
if key == nil {
|
||||||
key = &c.prm.key
|
key = &c.prm.Key
|
||||||
}
|
}
|
||||||
|
|
||||||
err = signature.SignServiceMessage(key, req)
|
err = signature.SignServiceMessage(key, req)
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (x *PrmSessionCreate) UseKey(key ecdsa.PrivateKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PrmSessionCreate) buildRequest(c *Client) (*v2session.CreateRequest, error) {
|
func (x *PrmSessionCreate) buildRequest(c *Client) (*v2session.CreateRequest, error) {
|
||||||
ownerKey := c.prm.key.PublicKey
|
ownerKey := c.prm.Key.PublicKey
|
||||||
if x.Key != nil {
|
if x.Key != nil {
|
||||||
ownerKey = x.Key.PublicKey
|
ownerKey = x.Key.PublicKey
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func (c *Client) SessionCreate(ctx context.Context, prm PrmSessionCreate) (*ResS
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil {
|
||||||
return nil, fmt.Errorf("sign request: %w", err)
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
pool/pool.go
36
pool/pool.go
|
@ -316,9 +316,10 @@ func (x *wrapperPrm) setGRPCDialOptions(opts []grpc.DialOption) {
|
||||||
// newWrapper creates a clientWrapper that implements the client interface.
|
// newWrapper creates a clientWrapper that implements the client interface.
|
||||||
func newWrapper(prm wrapperPrm) *clientWrapper {
|
func newWrapper(prm wrapperPrm) *clientWrapper {
|
||||||
var cl sdkClient.Client
|
var cl sdkClient.Client
|
||||||
var prmInit sdkClient.PrmInit
|
prmInit := sdkClient.PrmInit{
|
||||||
prmInit.SetDefaultPrivateKey(prm.key)
|
Key: prm.key,
|
||||||
prmInit.SetResponseInfoCallback(prm.responseInfoCallback)
|
ResponseInfoCallback: prm.responseInfoCallback,
|
||||||
|
}
|
||||||
|
|
||||||
cl.Init(prmInit)
|
cl.Init(prmInit)
|
||||||
|
|
||||||
|
@ -340,11 +341,12 @@ func (c *clientWrapper) dial(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var prmDial sdkClient.PrmDial
|
prmDial := sdkClient.PrmDial{
|
||||||
prmDial.SetServerURI(c.prm.address)
|
Endpoint: c.prm.address,
|
||||||
prmDial.SetTimeout(c.prm.dialTimeout)
|
DialTimeout: c.prm.dialTimeout,
|
||||||
prmDial.SetStreamTimeout(c.prm.streamTimeout)
|
StreamTimeout: c.prm.streamTimeout,
|
||||||
prmDial.SetGRPCDialOptions(c.prm.dialOptions...)
|
GRPCDialOptions: c.prm.dialOptions,
|
||||||
|
}
|
||||||
|
|
||||||
if err = cl.Dial(ctx, prmDial); err != nil {
|
if err = cl.Dial(ctx, prmDial); err != nil {
|
||||||
c.setUnhealthyOnDial()
|
c.setUnhealthyOnDial()
|
||||||
|
@ -371,17 +373,19 @@ func (c *clientWrapper) restartIfUnhealthy(ctx context.Context) (healthy, change
|
||||||
}
|
}
|
||||||
|
|
||||||
var cl sdkClient.Client
|
var cl sdkClient.Client
|
||||||
var prmInit sdkClient.PrmInit
|
prmInit := sdkClient.PrmInit{
|
||||||
prmInit.SetDefaultPrivateKey(c.prm.key)
|
Key: c.prm.key,
|
||||||
prmInit.SetResponseInfoCallback(c.prm.responseInfoCallback)
|
ResponseInfoCallback: c.prm.responseInfoCallback,
|
||||||
|
}
|
||||||
|
|
||||||
cl.Init(prmInit)
|
cl.Init(prmInit)
|
||||||
|
|
||||||
var prmDial sdkClient.PrmDial
|
prmDial := sdkClient.PrmDial{
|
||||||
prmDial.SetServerURI(c.prm.address)
|
Endpoint: c.prm.address,
|
||||||
prmDial.SetTimeout(c.prm.dialTimeout)
|
DialTimeout: c.prm.dialTimeout,
|
||||||
prmDial.SetStreamTimeout(c.prm.streamTimeout)
|
StreamTimeout: c.prm.streamTimeout,
|
||||||
prmDial.SetGRPCDialOptions(c.prm.dialOptions...)
|
GRPCDialOptions: c.prm.dialOptions,
|
||||||
|
}
|
||||||
|
|
||||||
if err := cl.Dial(ctx, prmDial); err != nil {
|
if err := cl.Dial(ctx, prmDial); err != nil {
|
||||||
c.setUnhealthyOnDial()
|
c.setUnhealthyOnDial()
|
||||||
|
|
Loading…
Reference in a new issue