From cda8f9df2e2057784c9e4e94a1669a857b75a155 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 14 Sep 2022 17:13:40 +0300 Subject: [PATCH] [#1786] services/control: Remove `WithDeletedObjectHandler` option Use storage engine directly instead. It is already provided in the options. Signed-off-by: Evgenii Stratonikov --- cmd/neofs-node/control.go | 11 ----------- pkg/services/control/server/gc.go | 10 ++++++---- pkg/services/control/server/server.go | 10 ---------- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/cmd/neofs-node/control.go b/cmd/neofs-node/control.go index e0cf1a658e..d173ced8ea 100644 --- a/cmd/neofs-node/control.go +++ b/cmd/neofs-node/control.go @@ -5,10 +5,8 @@ import ( "net" controlconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/control" - "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" "github.com/nspcc-dev/neofs-node/pkg/services/control" controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server" - oid "github.com/nspcc-dev/neofs-sdk-go/object/id" "google.golang.org/grpc" ) @@ -33,15 +31,6 @@ func initControlService(c *cfg) { controlSvc.WithHealthChecker(c), controlSvc.WithNetMapSource(c.netMapSource), controlSvc.WithNodeState(c), - controlSvc.WithDeletedObjectHandler(func(addrList []oid.Address) error { - var prm engine.DeletePrm - prm.WithAddresses(addrList...) - prm.WithForceRemoval() - - _, err := c.cfgObject.cfgLocalStorage.localStorage.Delete(prm) - - return err - }), controlSvc.WithLocalStorage(c.cfgObject.cfgLocalStorage.localStorage), controlSvc.WithTreeService(c.treeService), ) diff --git a/pkg/services/control/server/gc.go b/pkg/services/control/server/gc.go index 15e37ffa34..0982cc2db9 100644 --- a/pkg/services/control/server/gc.go +++ b/pkg/services/control/server/gc.go @@ -4,15 +4,13 @@ import ( "context" "fmt" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" "github.com/nspcc-dev/neofs-node/pkg/services/control" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -// DeletedObjectHandler is a handler of objects to be removed. -type DeletedObjectHandler func([]oid.Address) error - // DropObjects marks objects to be removed from the local node. // // Objects are marked via garbage collector's callback. @@ -37,7 +35,11 @@ func (s *Server) DropObjects(_ context.Context, req *control.DropObjectsRequest) } } - err := s.delObjHandler(addrList) + var prm engine.DeletePrm + prm.WithAddresses(addrList...) + prm.WithForceRemoval() + + _, err := s.s.Delete(prm) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/pkg/services/control/server/server.go b/pkg/services/control/server/server.go index f1b0e5736a..682900ad56 100644 --- a/pkg/services/control/server/server.go +++ b/pkg/services/control/server/server.go @@ -49,8 +49,6 @@ type cfg struct { nodeState NodeState - delObjHandler DeletedObjectHandler - treeService TreeService s *engine.StorageEngine @@ -111,14 +109,6 @@ func WithNodeState(state NodeState) Option { } } -// WithDeletedObjectHandler returns option to function -// which is called on the objects being deleted. -func WithDeletedObjectHandler(h DeletedObjectHandler) Option { - return func(c *cfg) { - c.delObjHandler = h - } -} - // WithLocalStorage returns option to set local storage engine that // contains information about shards. func WithLocalStorage(engine *engine.StorageEngine) Option {