From a6c9a337cd1177ac07a066b6b29de0ae5ef88e5c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 6 Feb 2024 20:29:39 +0300 Subject: [PATCH] [#965] morph: Get rid of container.List invocations ContainersOf() is better in almost every aspect, besides creating a session when the containers number is between 1024 and 2048 (prefetch script does limited unwrapping). Making List() private helps to ensure it is no longer used and can be safely removed in future. Signed-off-by: Evgenii Stratonikov --- cmd/frostfs-node/container.go | 6 +++--- pkg/morph/client/container/containers_of.go | 2 +- pkg/morph/client/container/list.go | 4 ++-- pkg/services/container/morph/executor.go | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/frostfs-node/container.go b/cmd/frostfs-node/container.go index 28f271075..d566c0af3 100644 --- a/cmd/frostfs-node/container.go +++ b/cmd/frostfs-node/container.go @@ -210,7 +210,7 @@ type morphContainerReader struct { src containerCore.Source lister interface { - List(*user.ID) ([]cid.ID, error) + ContainersOf(*user.ID) ([]cid.ID, error) } } @@ -226,8 +226,8 @@ func (x *morphContainerReader) GetEACL(id cid.ID) (*containerCore.EACL, error) { return x.eacl.GetEACL(id) } -func (x *morphContainerReader) List(id *user.ID) ([]cid.ID, error) { - return x.lister.List(id) +func (x *morphContainerReader) ContainersOf(id *user.ID) ([]cid.ID, error) { + return x.lister.ContainersOf(id) } type morphContainerWriter struct { diff --git a/pkg/morph/client/container/containers_of.go b/pkg/morph/client/container/containers_of.go index ce127335d..c4db0fe6e 100644 --- a/pkg/morph/client/container/containers_of.go +++ b/pkg/morph/client/container/containers_of.go @@ -53,7 +53,7 @@ func (c *Client) ContainersOf(idUser *user.ID) ([]cid.ID, error) { err := c.client.Morph().TestInvokeIterator(cb, batchSize, cnrHash, containersOfMethod, rawID) if err != nil { if errors.Is(err, unwrap.ErrNoSessionID) { - return c.List(idUser) + return c.list(idUser) } return nil, err } diff --git a/pkg/morph/client/container/list.go b/pkg/morph/client/container/list.go index 8f165f4b1..6fed46c1a 100644 --- a/pkg/morph/client/container/list.go +++ b/pkg/morph/client/container/list.go @@ -8,13 +8,13 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user" ) -// List returns a list of container identifiers belonging +// list returns a list of container identifiers belonging // to the specified user of FrostFS system. The list is composed // through Container contract call. // // Returns the identifiers of all FrostFS containers if pointer // to user identifier is nil. -func (c *Client) List(idUser *user.ID) ([]cid.ID, error) { +func (c *Client) list(idUser *user.ID) ([]cid.ID, error) { var rawID []byte if idUser != nil { diff --git a/pkg/services/container/morph/executor.go b/pkg/services/container/morph/executor.go index dec022219..f1217705e 100644 --- a/pkg/services/container/morph/executor.go +++ b/pkg/services/container/morph/executor.go @@ -26,10 +26,10 @@ type Reader interface { containercore.Source containercore.EACLSource - // List returns a list of container identifiers belonging + // ContainersOf returns a list of container identifiers belonging // to the specified user of FrostFS system. Returns the identifiers // of all FrostFS containers if pointer to owner identifier is nil. - List(*user.ID) ([]cid.ID, error) + ContainersOf(*user.ID) ([]cid.ID, error) } // Writer is an interface of container storage updater. @@ -187,7 +187,7 @@ func (s *morphExecutor) List(_ context.Context, body *container.ListRequestBody) return nil, fmt.Errorf("invalid user ID: %w", err) } - cnrs, err := s.rdr.List(&id) + cnrs, err := s.rdr.ContainersOf(&id) if err != nil { return nil, err }