Added method `GetShardByObjectID` to ControlService and to StorageEngine. It returns information about shards storing object on the node. Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
36 lines
842 B
Go
36 lines
842 B
Go
package shard
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
)
|
|
|
|
var ErrObjectFound = errors.New("found object")
|
|
|
|
type SearchPrm struct {
|
|
ObjectID oid.ID
|
|
ContainerID cid.ID
|
|
}
|
|
|
|
func GetObjectIteratePrm(prm SearchPrm) IterateOverObjectsInContainerPrm {
|
|
return IterateOverObjectsInContainerPrm{
|
|
ObjectType: objectSDK.TypeRegular,
|
|
ContainerID: prm.ContainerID,
|
|
Handler: func(ctx context.Context, i *object.Info) error {
|
|
select {
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
default:
|
|
}
|
|
if i.Address.Object().Equals(prm.ObjectID) {
|
|
return ErrObjectFound
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
}
|