[#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:
parent
ae1dab29bc
commit
cda8f9df2e
3 changed files with 6 additions and 25 deletions
|
@ -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),
|
||||
)
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue