forked from TrueCloudLab/frostfs-node
[#58] object/delete: Process linking object in Delete service
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
16252ad09a
commit
f251645def
3 changed files with 81 additions and 2 deletions
40
pkg/services/object/head/relation.go
Normal file
40
pkg/services/object/head/relation.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package headsvc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type RelationHeader struct {
|
||||
srch RelationSearcher
|
||||
|
||||
svc *Service
|
||||
}
|
||||
|
||||
func NewRelationHeader(srch RelationSearcher, svc *Service) *RelationHeader {
|
||||
return &RelationHeader{
|
||||
srch: srch,
|
||||
svc: svc,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *RelationHeader) HeadRelation(ctx context.Context, addr *objectSDK.Address) (*object.Object, error) {
|
||||
id, err := h.srch.SearchRelation(ctx, addr)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "(%T) could not find relation", h)
|
||||
}
|
||||
|
||||
a := objectSDK.NewAddress()
|
||||
a.SetContainerID(addr.GetContainerID())
|
||||
a.SetObjectID(id)
|
||||
|
||||
r, err := h.svc.Head(ctx, new(Prm).WithAddress(a))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "(%T) could not receive relation header", h)
|
||||
}
|
||||
|
||||
return r.Header(), nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue