From 342524159ac33b9bc01df3696ebb151538acd581 Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Fri, 18 Aug 2023 18:07:51 +0300 Subject: [PATCH] [#121] pool: Make PrmContainerSetEACL fields public Signed-off-by: Airat Arifullin --- pool/pool.go | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/pool/pool.go b/pool/pool.go index b603951..06c317c 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -549,11 +549,9 @@ func (c *clientWrapper) containerSetEACL(ctx context.Context, prm PrmContainerSe return err } - var cliPrm sdkClient.PrmContainerSetEACL - cliPrm.SetTable(prm.table) - - if prm.sessionSet { - cliPrm.WithinSession(prm.session) + cliPrm := sdkClient.PrmContainerSetEACL{ + Table: &prm.Table, + Session: prm.Session, } start := time.Now() @@ -567,16 +565,19 @@ func (c *clientWrapper) containerSetEACL(ctx context.Context, prm PrmContainerSe return fmt.Errorf("set eacl on client: %w", err) } - if !prm.waitParamsSet { - prm.waitParams.setDefaults() + if prm.WaitParams == nil { + prm.WaitParams = defaultWaitParams() + } + if err := prm.WaitParams.CheckValidity(); err != nil { + return fmt.Errorf("invalid wait parameters: %w", err) } var cIDp *cid.ID - if cID, set := prm.table.CID(); set { + if cID, set := prm.Table.CID(); set { cIDp = &cID } - err = waitForEACLPresence(ctx, c, cIDp, &prm.table, &prm.waitParams) + err = waitForEACLPresence(ctx, c, cIDp, &prm.Table, prm.WaitParams) if err = c.handleError(ctx, nil, err); err != nil { return fmt.Errorf("wait eacl presence on client: %w", err) } @@ -1227,12 +1228,6 @@ func (x *WaitParams) SetPollInterval(tick time.Duration) { x.PollInterval = tick } -// Deprecated: Use defaultWaitParams() instead. -func (x *WaitParams) setDefaults() { - x.Timeout = 120 * time.Second - x.PollInterval = 5 * time.Second -} - func defaultWaitParams() *WaitParams { return &WaitParams{ Timeout: 120 * time.Second, @@ -1532,39 +1527,41 @@ func (x *PrmContainerEACL) SetContainerID(cnrID cid.ID) { // PrmContainerSetEACL groups parameters of SetEACL operation. type PrmContainerSetEACL struct { - table eacl.Table + Table eacl.Table - sessionSet bool - session session.Container + Session *session.Container - waitParams WaitParams - waitParamsSet bool + WaitParams *WaitParams } // SetTable sets structure of container's extended ACL to be used as a // parameter of the base client's operation. // // See git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client.PrmContainerSetEACL.SetTable. +// +// Deprecated: Use PrmContainerSetEACL.Table instead. func (x *PrmContainerSetEACL) SetTable(table eacl.Table) { - x.table = table + x.Table = table } // WithinSession specifies session to be used as a parameter of the base // client's operation. // // See git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client.PrmContainerSetEACL.WithinSession. +// +// Deprecated: Use PrmContainerSetEACL.Session instead. func (x *PrmContainerSetEACL) WithinSession(s session.Container) { - x.session = s - x.sessionSet = true + x.Session = &s } // SetWaitParams specifies timeout params to complete operation. // If not provided the default one will be used. // Panics if any of the wait params isn't positive. +// +// Deprecated: Use PrmContainerSetEACL.WaitParams instead. func (x *PrmContainerSetEACL) SetWaitParams(waitParams WaitParams) { waitParams.checkForPositive() - x.waitParams = waitParams - x.waitParamsSet = true + x.WaitParams = &waitParams } // PrmBalanceGet groups parameters of Balance operation.