From 805ad54f41481a29e20e73b2c7fcd4449c2d6a2c Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 27 Oct 2020 15:54:02 +0300 Subject: [PATCH] [#180] sdk/client: Make defaultOptions func a Client method Signed-off-by: Leonard Lyubich --- pkg/client/accounting.go | 2 +- pkg/client/container.go | 12 ++++++------ pkg/client/netmap.go | 2 +- pkg/client/object.go | 14 +++++++------- pkg/client/opts.go | 2 +- pkg/client/session.go | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pkg/client/accounting.go b/pkg/client/accounting.go index 92c5e128..52d25c4d 100644 --- a/pkg/client/accounting.go +++ b/pkg/client/accounting.go @@ -35,7 +35,7 @@ func (c Client) GetBalance(ctx context.Context, owner *owner.ID, opts ...CallOpt func (c Client) getBalanceV2(ctx context.Context, owner *owner.ID, opts ...CallOption) (*accounting.Decimal, error) { // apply all available options - callOptions := defaultCallOptions() + callOptions := c.defaultCallOptions() for i := range opts { opts[i].apply(&callOptions) } diff --git a/pkg/client/container.go b/pkg/client/container.go index e4eb75ad..c723de13 100644 --- a/pkg/client/container.go +++ b/pkg/client/container.go @@ -94,7 +94,7 @@ func (c Client) SetEACL(ctx context.Context, eacl *eacl.Table, opts ...CallOptio func (c Client) putContainerV2(ctx context.Context, cnr *container.Container, opts ...CallOption) (*container.ID, error) { // apply all available options - callOptions := defaultCallOptions() + callOptions := c.defaultCallOptions() for i := range opts { opts[i].apply(&callOptions) } @@ -164,7 +164,7 @@ func (c Client) putContainerV2(ctx context.Context, cnr *container.Container, op func (c Client) getContainerV2(ctx context.Context, id *container.ID, opts ...CallOption) (*container.Container, error) { // apply all available options - callOptions := defaultCallOptions() + callOptions := c.defaultCallOptions() for i := range opts { opts[i].apply(&callOptions) } @@ -206,7 +206,7 @@ func (c Client) getContainerV2(ctx context.Context, id *container.ID, opts ...Ca func (c Client) listContainerV2(ctx context.Context, owner *owner.ID, opts ...CallOption) ([]*container.ID, error) { // apply all available options - callOptions := defaultCallOptions() + callOptions := c.defaultCallOptions() for i := range opts { opts[i].apply(&callOptions) } @@ -253,7 +253,7 @@ func (c Client) listContainerV2(ctx context.Context, owner *owner.ID, opts ...Ca func (c Client) delContainerV2(ctx context.Context, id *container.ID, opts ...CallOption) error { // apply all available options - callOptions := defaultCallOptions() + callOptions := c.defaultCallOptions() for i := range opts { opts[i].apply(&callOptions) } @@ -311,7 +311,7 @@ func (c Client) delContainerV2(ctx context.Context, id *container.ID, opts ...Ca func (c Client) getEACLV2(ctx context.Context, id *container.ID, opts ...CallOption) (*eacl.Table, error) { // apply all available options - callOptions := defaultCallOptions() + callOptions := c.defaultCallOptions() for i := range opts { opts[i].apply(&callOptions) } @@ -362,7 +362,7 @@ func (c Client) getEACLV2(ctx context.Context, id *container.ID, opts ...CallOpt func (c Client) setEACLV2(ctx context.Context, eacl *eacl.Table, opts ...CallOption) error { // apply all available options - callOptions := defaultCallOptions() + callOptions := c.defaultCallOptions() for i := range opts { opts[i].apply(&callOptions) } diff --git a/pkg/client/netmap.go b/pkg/client/netmap.go index c400332e..515d1309 100644 --- a/pkg/client/netmap.go +++ b/pkg/client/netmap.go @@ -23,7 +23,7 @@ func (c Client) EndpointInfo(ctx context.Context, opts ...CallOption) (*netmap.N func (c Client) endpointInfoV2(ctx context.Context, opts ...CallOption) (*netmap.NodeInfo, error) { // apply all available options - callOptions := defaultCallOptions() + callOptions := c.defaultCallOptions() for i := range opts { opts[i].apply(&callOptions) } diff --git a/pkg/client/object.go b/pkg/client/object.go index 1784af39..5d29e5dd 100644 --- a/pkg/client/object.go +++ b/pkg/client/object.go @@ -164,7 +164,7 @@ func (c *Client) putObjectV2(ctx context.Context, p *PutObjectParams, opts ...Ca return nil, errors.Wrap(err, "could not open Put object stream") } - callOpts := defaultCallOptions() + callOpts := c.defaultCallOptions() for i := range opts { if opts[i] != nil { @@ -279,7 +279,7 @@ func (c *Client) deleteObjectV2(ctx context.Context, p *DeleteObjectParams, opts return errors.Wrap(err, "could not create Object V2 client") } - callOpts := defaultCallOptions() + callOpts := c.defaultCallOptions() for i := range opts { if opts[i] != nil { @@ -359,7 +359,7 @@ func (c *Client) getObjectV2(ctx context.Context, p *GetObjectParams, opts ...Ca return nil, errors.Wrap(err, "could not create Object V2 client") } - callOpts := defaultCallOptions() + callOpts := c.defaultCallOptions() for i := range opts { if opts[i] != nil { @@ -492,7 +492,7 @@ func (c *Client) getObjectHeaderV2(ctx context.Context, p *ObjectHeaderParams, o return nil, errors.Wrap(err, "could not create Object V2 client") } - callOpts := defaultCallOptions() + callOpts := c.defaultCallOptions() for i := range opts { if opts[i] != nil { @@ -625,7 +625,7 @@ func (c *Client) objectPayloadRangeV2(ctx context.Context, p *RangeDataParams, o return nil, errors.Wrap(err, "could not create Object V2 client") } - callOpts := defaultCallOptions() + callOpts := c.defaultCallOptions() for i := range opts { if opts[i] != nil { @@ -767,7 +767,7 @@ func (c *Client) objectPayloadRangeHashV2(ctx context.Context, p *RangeChecksumP return nil, errors.Wrap(err, "could not create Object V2 client") } - callOpts := defaultCallOptions() + callOpts := c.defaultCallOptions() for i := range opts { if opts[i] != nil { @@ -899,7 +899,7 @@ func (c *Client) searchObjectV2(ctx context.Context, p *SearchObjectParams, opts return nil, errors.Wrap(err, "could not create Object V2 client") } - callOpts := defaultCallOptions() + callOpts := c.defaultCallOptions() for i := range opts { if opts[i] != nil { diff --git a/pkg/client/opts.go b/pkg/client/opts.go index ff3546d8..f8d2528b 100644 --- a/pkg/client/opts.go +++ b/pkg/client/opts.go @@ -58,7 +58,7 @@ type ( } ) -func defaultCallOptions() callOptions { +func (c Client) defaultCallOptions() callOptions { return callOptions{ ttl: 2, version: pkg.SDKVersion(), diff --git a/pkg/client/session.go b/pkg/client/session.go index 6c912a02..48d0806b 100644 --- a/pkg/client/session.go +++ b/pkg/client/session.go @@ -22,7 +22,7 @@ func (c Client) CreateSession(ctx context.Context, expiration uint64, opts ...Ca func (c Client) createSessionV2(ctx context.Context, expiration uint64, opts ...CallOption) (*token.SessionToken, error) { // apply all available options - callOptions := defaultCallOptions() + callOptions := c.defaultCallOptions() for i := range opts { opts[i].apply(&callOptions) }