[#180] sdk/client: Make defaultOptions func a Client method

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-10-27 15:54:02 +03:00 committed by Alex Vanin
parent ad0b01e892
commit 805ad54f41
6 changed files with 17 additions and 17 deletions

View file

@ -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) { func (c Client) getBalanceV2(ctx context.Context, owner *owner.ID, opts ...CallOption) (*accounting.Decimal, error) {
// apply all available options // apply all available options
callOptions := defaultCallOptions() callOptions := c.defaultCallOptions()
for i := range opts { for i := range opts {
opts[i].apply(&callOptions) opts[i].apply(&callOptions)
} }

View file

@ -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) { func (c Client) putContainerV2(ctx context.Context, cnr *container.Container, opts ...CallOption) (*container.ID, error) {
// apply all available options // apply all available options
callOptions := defaultCallOptions() callOptions := c.defaultCallOptions()
for i := range opts { for i := range opts {
opts[i].apply(&callOptions) 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) { func (c Client) getContainerV2(ctx context.Context, id *container.ID, opts ...CallOption) (*container.Container, error) {
// apply all available options // apply all available options
callOptions := defaultCallOptions() callOptions := c.defaultCallOptions()
for i := range opts { for i := range opts {
opts[i].apply(&callOptions) 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) { func (c Client) listContainerV2(ctx context.Context, owner *owner.ID, opts ...CallOption) ([]*container.ID, error) {
// apply all available options // apply all available options
callOptions := defaultCallOptions() callOptions := c.defaultCallOptions()
for i := range opts { for i := range opts {
opts[i].apply(&callOptions) 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 { func (c Client) delContainerV2(ctx context.Context, id *container.ID, opts ...CallOption) error {
// apply all available options // apply all available options
callOptions := defaultCallOptions() callOptions := c.defaultCallOptions()
for i := range opts { for i := range opts {
opts[i].apply(&callOptions) 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) { func (c Client) getEACLV2(ctx context.Context, id *container.ID, opts ...CallOption) (*eacl.Table, error) {
// apply all available options // apply all available options
callOptions := defaultCallOptions() callOptions := c.defaultCallOptions()
for i := range opts { for i := range opts {
opts[i].apply(&callOptions) 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 { func (c Client) setEACLV2(ctx context.Context, eacl *eacl.Table, opts ...CallOption) error {
// apply all available options // apply all available options
callOptions := defaultCallOptions() callOptions := c.defaultCallOptions()
for i := range opts { for i := range opts {
opts[i].apply(&callOptions) opts[i].apply(&callOptions)
} }

View file

@ -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) { func (c Client) endpointInfoV2(ctx context.Context, opts ...CallOption) (*netmap.NodeInfo, error) {
// apply all available options // apply all available options
callOptions := defaultCallOptions() callOptions := c.defaultCallOptions()
for i := range opts { for i := range opts {
opts[i].apply(&callOptions) opts[i].apply(&callOptions)
} }

View file

@ -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") return nil, errors.Wrap(err, "could not open Put object stream")
} }
callOpts := defaultCallOptions() callOpts := c.defaultCallOptions()
for i := range opts { for i := range opts {
if opts[i] != nil { 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") return errors.Wrap(err, "could not create Object V2 client")
} }
callOpts := defaultCallOptions() callOpts := c.defaultCallOptions()
for i := range opts { for i := range opts {
if opts[i] != nil { 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") return nil, errors.Wrap(err, "could not create Object V2 client")
} }
callOpts := defaultCallOptions() callOpts := c.defaultCallOptions()
for i := range opts { for i := range opts {
if opts[i] != nil { 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") return nil, errors.Wrap(err, "could not create Object V2 client")
} }
callOpts := defaultCallOptions() callOpts := c.defaultCallOptions()
for i := range opts { for i := range opts {
if opts[i] != nil { 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") return nil, errors.Wrap(err, "could not create Object V2 client")
} }
callOpts := defaultCallOptions() callOpts := c.defaultCallOptions()
for i := range opts { for i := range opts {
if opts[i] != nil { 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") return nil, errors.Wrap(err, "could not create Object V2 client")
} }
callOpts := defaultCallOptions() callOpts := c.defaultCallOptions()
for i := range opts { for i := range opts {
if opts[i] != nil { 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") return nil, errors.Wrap(err, "could not create Object V2 client")
} }
callOpts := defaultCallOptions() callOpts := c.defaultCallOptions()
for i := range opts { for i := range opts {
if opts[i] != nil { if opts[i] != nil {

View file

@ -58,7 +58,7 @@ type (
} }
) )
func defaultCallOptions() callOptions { func (c Client) defaultCallOptions() callOptions {
return callOptions{ return callOptions{
ttl: 2, ttl: 2,
version: pkg.SDKVersion(), version: pkg.SDKVersion(),

View file

@ -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) { func (c Client) createSessionV2(ctx context.Context, expiration uint64, opts ...CallOption) (*token.SessionToken, error) {
// apply all available options // apply all available options
callOptions := defaultCallOptions() callOptions := c.defaultCallOptions()
for i := range opts { for i := range opts {
opts[i].apply(&callOptions) opts[i].apply(&callOptions)
} }