frostfs-node/pkg/local_object_storage/shard/move.go
Leonard Lyubich 590745204c [#237] metabase: Structure parameters and results of all operations
All parameters and resulting values of all metabase operations are
structured in new types. The most popular scenarios for using operations are
moved to auxiliary functions.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-12-11 17:19:37 +03:00

38 lines
962 B
Go

package shard
import (
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"go.uber.org/zap"
)
// ToMoveItPrm encapsulates parameters for ToMoveIt operation.
type ToMoveItPrm struct {
addr *objectSDK.Address
}
// ToMoveItRes encapsulates results of ToMoveIt operation.
type ToMoveItRes struct{}
// WithAdderss sets object address that should be marked to move into another
// shard.
func (p *ToMoveItPrm) WithAddress(addr *objectSDK.Address) *ToMoveItPrm {
if p != nil {
p.addr = addr
}
return p
}
// ToMoveIt calls metabase.ToMoveIt method to mark object as relocatable to
// another shard.
func (s *Shard) ToMoveIt(prm *ToMoveItPrm) (*ToMoveItRes, error) {
err := meta.ToMoveIt(s.metaBase, prm.addr)
if err != nil {
s.log.Debug("could not mark object for shard relocation in metabase",
zap.String("error", err.Error()),
)
}
return new(ToMoveItRes), nil
}