neofs: add ObjectSearchInitter

With ObjectSearchInitter ObjectSearch can can be done by both NeoFS SDK
client and pool.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
Ekaterina Pavlova 2024-10-09 00:52:54 +03:00
parent 86ed214e8a
commit 2435484dc4

View file

@ -236,8 +236,13 @@ func parseRange(s string) (*object.Range, error) {
return r, nil return r, nil
} }
// ObjectSearchInitter defines the interface for initializing object search.
type ObjectSearchInitter interface {
ObjectSearchInit(ctx context.Context, containerID cid.ID, s user.Signer, prm client.PrmObjectSearch) (*client.ObjectListReader, error)
}
// ObjectSearch returns a list of object IDs from the provided container. // ObjectSearch returns a list of object IDs from the provided container.
func ObjectSearch(ctx context.Context, c *client.Client, priv *keys.PrivateKey, containerIDStr string, prm client.PrmObjectSearch) ([]oid.ID, error) { func ObjectSearch(ctx context.Context, initter ObjectSearchInitter, priv *keys.PrivateKey, containerIDStr string, prm client.PrmObjectSearch) ([]oid.ID, error) {
var ( var (
s = user.NewAutoIDSignerRFC6979(priv.PrivateKey) s = user.NewAutoIDSignerRFC6979(priv.PrivateKey)
objectIDs []oid.ID objectIDs []oid.ID
@ -247,7 +252,7 @@ func ObjectSearch(ctx context.Context, c *client.Client, priv *keys.PrivateKey,
if err != nil { if err != nil {
return nil, fmt.Errorf("%w: %w", ErrInvalidContainer, err) return nil, fmt.Errorf("%w: %w", ErrInvalidContainer, err)
} }
reader, err := c.ObjectSearchInit(ctx, containerID, s, prm) reader, err := initter.ObjectSearchInit(ctx, containerID, s, prm)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to initiate object search: %w", err) return nil, fmt.Errorf("failed to initiate object search: %w", err)
} }