2020-12-01 07:40:58 +00:00
|
|
|
package shard
|
|
|
|
|
|
|
|
import (
|
|
|
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
2020-12-08 09:56:14 +00:00
|
|
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
2020-12-01 07:40:58 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
// InhumePrm encapsulates parameters for inhume operation.
|
|
|
|
type InhumePrm struct {
|
|
|
|
target *objectSDK.Address
|
|
|
|
tombstone *objectSDK.Address
|
|
|
|
}
|
|
|
|
|
|
|
|
// InhumeRes encapsulates results of inhume operation.
|
|
|
|
type InhumeRes struct{}
|
|
|
|
|
|
|
|
// WithTarget sets object address that should be inhumed and tombstone address
|
|
|
|
// as the reason for inhume operation.
|
|
|
|
func (p *InhumePrm) WithTarget(addr, tombstone *objectSDK.Address) *InhumePrm {
|
|
|
|
if p != nil {
|
|
|
|
p.target = addr
|
|
|
|
p.tombstone = tombstone
|
|
|
|
}
|
|
|
|
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inhume calls metabase. Inhume method to mark object as removed. It won't be
|
|
|
|
// removed physically from blobStor and metabase until `Delete` operation.
|
|
|
|
func (s *Shard) Inhume(prm *InhumePrm) (*InhumeRes, error) {
|
2020-12-08 09:56:14 +00:00
|
|
|
err := meta.Inhume(s.metaBase, prm.target, prm.tombstone)
|
2020-12-01 07:40:58 +00:00
|
|
|
if err != nil {
|
|
|
|
s.log.Debug("could not mark object to delete in metabase",
|
|
|
|
zap.String("error", err.Error()),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return new(InhumeRes), nil
|
|
|
|
}
|