[#377] shard: Support batch Inhume operation

Replace single target address in `InhumePrm` with the list of addresses.
Change corresponding parameter in `WithTarget` and `MarkAsGarbage` methods
to variadic.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-02-15 15:02:22 +03:00 committed by Alex Vanin
parent 0d6d195d0d
commit 3d7d074af4
3 changed files with 9 additions and 9 deletions

View file

@ -32,7 +32,7 @@ var errInhumeFailure = errors.New("inhume operation failed")
// Inhume calls metabase. Inhume method to mark object as removed. It won't be
// removed physically from shard until `Delete` operation.
func (e *StorageEngine) Inhume(prm *InhumePrm) (*InhumeRes, error) {
shPrm := new(shard.InhumePrm).WithTarget(prm.addr, prm.tombstone)
shPrm := new(shard.InhumePrm).WithTarget(prm.tombstone, prm.addr)
res := e.inhume(prm.addr, shPrm, true)
if res == nil {

View file

@ -8,21 +8,21 @@ import (
// InhumePrm encapsulates parameters for inhume operation.
type InhumePrm struct {
target *objectSDK.Address
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
// WithTarget sets list of objects that should be inhumed and tombstone address
// as the reason for inhume operation.
//
// Arguments should not be nil.
// tombstone should not be nil, addr should not be empty.
// Should not be called along with MarkAsGarbage.
func (p *InhumePrm) WithTarget(addr, tombstone *objectSDK.Address) *InhumePrm {
func (p *InhumePrm) WithTarget(tombstone *objectSDK.Address, addrs ...*objectSDK.Address) *InhumePrm {
if p != nil {
p.target = addr
p.target = addrs
p.tombstone = tombstone
}
@ -32,7 +32,7 @@ func (p *InhumePrm) WithTarget(addr, tombstone *objectSDK.Address) *InhumePrm {
// MarkAsGarbage marks object to be physically removed from shard.
//
// Should not be called along with WithTarget.
func (p *InhumePrm) MarkAsGarbage(addr *objectSDK.Address) *InhumePrm {
func (p *InhumePrm) MarkAsGarbage(addr ...*objectSDK.Address) *InhumePrm {
if p != nil {
p.target = addr
p.tombstone = nil
@ -44,7 +44,7 @@ func (p *InhumePrm) MarkAsGarbage(addr *objectSDK.Address) *InhumePrm {
// 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) {
metaPrm := new(meta.InhumePrm).WithAddress(prm.target)
metaPrm := new(meta.InhumePrm).WithAddresses(prm.target...)
if prm.tombstone != nil {
metaPrm.WithTombstoneAddress(prm.tombstone)

View file

@ -38,7 +38,7 @@ func testShardInhume(t *testing.T, sh *shard.Shard) {
putPrm.WithObject(obj.Object())
inhPrm := new(shard.InhumePrm)
inhPrm.WithTarget(obj.Object().Address(), ts.Object().Address())
inhPrm.WithTarget(ts.Object().Address(), obj.Object().Address())
getPrm := new(shard.GetPrm)
getPrm.WithAddress(obj.Object().Address())