[#64] object/delete: Change the formation of tombstone
Make delete service to write list of child object addresses to tombstone payload. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
33ca88f85f
commit
44fcd2f212
2 changed files with 73 additions and 100 deletions
|
@ -1,29 +1,12 @@
|
|||
package deletesvc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type deleteTool struct {
|
||||
ctx context.Context
|
||||
|
||||
putSvc *putsvc.Service
|
||||
|
||||
obj *object.RawObject
|
||||
|
||||
addr *objectSDK.Address
|
||||
|
||||
commonPrm *util.CommonPrm
|
||||
}
|
||||
|
||||
func newTombstone(ownerID *owner.ID, cid *container.ID) *object.RawObject {
|
||||
obj := object.NewRaw()
|
||||
obj.SetContainerID(cid)
|
||||
|
@ -32,40 +15,3 @@ func newTombstone(ownerID *owner.ID, cid *container.ID) *object.RawObject {
|
|||
|
||||
return obj
|
||||
}
|
||||
|
||||
func (d *deleteTool) delete(id *objectSDK.ID) error {
|
||||
d.addr.SetObjectID(id)
|
||||
|
||||
// FIXME: implement marshaler
|
||||
addrBytes, err := d.addr.ToV2().StableMarshal(nil)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "(%T) could not marshal address", d)
|
||||
}
|
||||
|
||||
r, err := d.putSvc.Put(d.ctx)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "(%T) could not open put stream", d)
|
||||
}
|
||||
|
||||
d.obj.SetID(id)
|
||||
d.obj.SetPayload(addrBytes)
|
||||
|
||||
if err := r.Init(new(putsvc.PutInitPrm).
|
||||
WithObject(d.obj).
|
||||
WithCommonPrm(d.commonPrm),
|
||||
); err != nil {
|
||||
return errors.Wrapf(err, "(%T) could not initialize tombstone stream", d)
|
||||
}
|
||||
|
||||
if err := r.SendChunk(new(putsvc.PutChunkPrm).
|
||||
WithChunk(addrBytes),
|
||||
); err != nil {
|
||||
return errors.Wrapf(err, "(%T) could not send tombstone payload", d)
|
||||
}
|
||||
|
||||
if _, err := r.Close(); err != nil {
|
||||
return errors.Wrapf(err, "(%T) could not close tombstone stream", d)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue