[#70] core/object: Process a delete group at tombstone

Send object group to delete queue processor after tombstone content
validation.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-10-03 13:14:09 +03:00 committed by Alex Vanin
parent 276ed6c04b
commit 798fca9354
3 changed files with 74 additions and 6 deletions

View file

@ -6,9 +6,11 @@ import (
"sync"
"github.com/mr-tron/base58"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-api-go/v2/object"
objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
objectCore "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
objectTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc"
@ -29,7 +31,9 @@ import (
searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search"
searchsvcV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/search/v2"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/panjf2000/ants/v2"
"go.uber.org/zap"
)
type objectSvc struct {
@ -157,6 +161,19 @@ func (s *objectSvc) GetRangeHash(ctx context.Context, req *object.GetRangeHashRe
return s.rngHash.GetRangeHash(ctx, req)
}
type deleteHandler struct {
log *logger.Logger
}
func (s *deleteHandler) DeleteObjects(list ...*objectSDK.Address) {
for i := range list {
s.log.Info("object is marked for removal",
zap.String("CID", base58.Encode(list[i].GetContainerID().ToV2().GetValue())),
zap.String("ID", base58.Encode(list[i].GetObjectID().ToV2().GetValue())),
)
}
}
func initObjectService(c *cfg) {
ls := localstore.New(
c.cfgObject.blobstorage,
@ -177,6 +194,9 @@ func initObjectService(c *cfg) {
putsvc.WithContainerSource(c.cfgObject.cnrStorage),
putsvc.WithNetworkMapSource(c.cfgObject.netMapStorage),
putsvc.WithLocalAddressSource(c),
putsvc.WithFormatValidatorOpts(
objectCore.WithDeleteHandler(&deleteHandler{c.log}),
),
)
sPutV2 := putsvcV2.NewService(