[#1786] services/control: Remove WithDeletedObjectHandler option

Use storage engine directly instead. It is already provided in the
options.

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-09-14 17:13:40 +03:00 committed by fyrchik
parent ae1dab29bc
commit cda8f9df2e
3 changed files with 6 additions and 25 deletions

View file

@ -5,10 +5,8 @@ import (
"net" "net"
controlconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/control" 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" "github.com/nspcc-dev/neofs-node/pkg/services/control"
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server" 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" "google.golang.org/grpc"
) )
@ -33,15 +31,6 @@ func initControlService(c *cfg) {
controlSvc.WithHealthChecker(c), controlSvc.WithHealthChecker(c),
controlSvc.WithNetMapSource(c.netMapSource), controlSvc.WithNetMapSource(c.netMapSource),
controlSvc.WithNodeState(c), 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.WithLocalStorage(c.cfgObject.cfgLocalStorage.localStorage),
controlSvc.WithTreeService(c.treeService), controlSvc.WithTreeService(c.treeService),
) )

View file

@ -4,15 +4,13 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/services/control" "github.com/nspcc-dev/neofs-node/pkg/services/control"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id" oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "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. // DropObjects marks objects to be removed from the local node.
// //
// Objects are marked via garbage collector's callback. // 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 { if err != nil {
return nil, status.Error(codes.Internal, err.Error()) return nil, status.Error(codes.Internal, err.Error())
} }

View file

@ -49,8 +49,6 @@ type cfg struct {
nodeState NodeState nodeState NodeState
delObjHandler DeletedObjectHandler
treeService TreeService treeService TreeService
s *engine.StorageEngine 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 // WithLocalStorage returns option to set local storage engine that
// contains information about shards. // contains information about shards.
func WithLocalStorage(engine *engine.StorageEngine) Option { func WithLocalStorage(engine *engine.StorageEngine) Option {