From 173d34a8a2166082b722c81d87a8004327188c78 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 8 Dec 2020 19:26:34 +0300 Subject: [PATCH] [#235] object/get: Set common operation parameters Signed-off-by: Leonard Lyubich --- pkg/services/object/get/prm.go | 5 +++++ pkg/services/object/get/v2/util.go | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/pkg/services/object/get/prm.go b/pkg/services/object/get/prm.go index 5d5600b27..1aa4d729f 100644 --- a/pkg/services/object/get/prm.go +++ b/pkg/services/object/get/prm.go @@ -92,3 +92,8 @@ func (p *RangeHashPrm) SetRangeList(rngs []*objectSDK.Range) { func (p *RangeHashPrm) SetHashGenerator(v func() hash.Hash) { p.hashGen = v } + +// SetCommonParameters sets common parameters of the operation. +func (p *commonPrm) SetCommonParameters(common *util.CommonPrm) { + p.common = common +} diff --git a/pkg/services/object/get/v2/util.go b/pkg/services/object/get/v2/util.go index c823dc3e4..a0b243d19 100644 --- a/pkg/services/object/get/v2/util.go +++ b/pkg/services/object/get/v2/util.go @@ -13,6 +13,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/v2/session" objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object" getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get" + "github.com/nspcc-dev/neofs-node/pkg/services/object/util" "github.com/nspcc-dev/tzhash/tz" "github.com/pkg/errors" ) @@ -33,6 +34,9 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre p.WithRawFlag(body.GetRaw()) p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...) p.SetObjectWriter(&streamObjectWriter{stream}) + p.SetCommonParameters(new(util.CommonPrm). + WithLocalOnly(meta.GetTTL() <= 1), + ) return p, nil } @@ -54,6 +58,7 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...) p.SetChunkWriter(&streamObjectRangeWriter{stream}) p.SetRange(object.NewRangeFromV2(body.GetRange())) + p.SetCommonParameters(commonParameters(meta)) return p, nil } @@ -72,6 +77,7 @@ func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.Ran body := req.GetBody() p.WithAddress(object.NewAddressFromV2(body.GetAddress())) p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...) + p.SetCommonParameters(commonParameters(meta)) rngsV2 := body.GetRanges() rngs := make([]*object.Range, 0, len(rngsV2)) @@ -117,6 +123,11 @@ func remoteCallOptionsFromMeta(meta *session.RequestMetaHeader) []client.CallOpt return opts } +func commonParameters(meta *session.RequestMetaHeader) *util.CommonPrm { + return new(util.CommonPrm). + WithLocalOnly(meta.GetTTL() <= 1) +} + func splitInfoResponse(info *object.SplitInfo) *objectV2.GetResponse { resp := new(objectV2.GetResponse)