From 72f8ca1afde09281f84f63d1a4eb1ae2cf3c501d Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 1 Dec 2020 10:40:58 +0300 Subject: [PATCH] [#222] Add Inhume method for shard Signed-off-by: Alex Vanin --- pkg/local_object_storage/shard/inhume.go | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pkg/local_object_storage/shard/inhume.go diff --git a/pkg/local_object_storage/shard/inhume.go b/pkg/local_object_storage/shard/inhume.go new file mode 100644 index 000000000..3e93c2d7d --- /dev/null +++ b/pkg/local_object_storage/shard/inhume.go @@ -0,0 +1,39 @@ +package shard + +import ( + objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" + "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) { + err := s.metaBase.Inhume(prm.target, prm.tombstone) + if err != nil { + s.log.Debug("could not mark object to delete in metabase", + zap.String("error", err.Error()), + ) + } + + return new(InhumeRes), nil +}