[#217] storage engine: Add GC marking to Inhume operation

Add `InhumePrm.MarkAsGarbage` method which marks passed objects to be
removed from local storage. Update `InhumePrm.WithTarget` doc to prevent
conflicting use with the new method.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-02-19 17:08:41 +03:00 committed by Alex Vanin
parent 7a4e3efa95
commit 35073fb61b

View file

@ -22,6 +22,7 @@ type InhumeRes struct{}
// as the reason for inhume operation.
//
// tombstone should not be nil, addr should not be empty.
// Should not be called along with MarkAsGarbage.
func (p *InhumePrm) WithTarget(tombstone *objectSDK.Address, addrs ...*objectSDK.Address) *InhumePrm {
if p != nil {
p.addrs = addrs
@ -31,6 +32,18 @@ func (p *InhumePrm) WithTarget(tombstone *objectSDK.Address, addrs ...*objectSDK
return p
}
// MarkAsGarbage marks object to be physically removed from local storage.
//
// Should not be called along with WithTarget.
func (p *InhumePrm) MarkAsGarbage(addrs ...*objectSDK.Address) *InhumePrm {
if p != nil {
p.addrs = addrs
p.tombstone = nil
}
return p
}
var errInhumeFailure = errors.New("inhume operation failed")
// Inhume calls metabase. Inhume method to mark object as removed. It won't be
@ -39,7 +52,11 @@ func (e *StorageEngine) Inhume(prm *InhumePrm) (*InhumeRes, error) {
shPrm := new(shard.InhumePrm)
for i := range prm.addrs {
if prm.tombstone != nil {
shPrm.WithTarget(prm.tombstone, prm.addrs[i])
} else {
shPrm.MarkAsGarbage(prm.addrs[i])
}
ok := e.inhume(prm.addrs[i], shPrm, true)
if ok {