frostfs-node/pkg/local_object_storage/shard/move.go
Leonard Lyubich 1c30414a6c [#1454] Upgrade NeoFS SDK Go module with new IDs
Core changes:
 * avoid package-colliding variable naming
 * avoid using pointers to IDs where unnecessary
 * avoid using `idSDK` import alias pattern
 * use `EncodeToString` for protocol string calculation and `String` for
  printing

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-06-01 17:41:45 +03:00

42 lines
1,010 B
Go

package shard
import (
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.uber.org/zap"
)
// ToMoveItPrm encapsulates parameters for ToMoveIt operation.
type ToMoveItPrm struct {
addr oid.Address
}
// ToMoveItRes encapsulates results of ToMoveIt operation.
type ToMoveItRes struct{}
// WithAddress sets object address that should be marked to move into another
// shard.
func (p *ToMoveItPrm) WithAddress(addr oid.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) {
if s.GetMode() != ModeReadWrite {
return nil, ErrReadOnlyMode
}
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
}