forked from TrueCloudLab/frostfs-node
[#235] object/get: Set common operation parameters
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7e56427534
commit
173d34a8a2
2 changed files with 16 additions and 0 deletions
|
@ -92,3 +92,8 @@ func (p *RangeHashPrm) SetRangeList(rngs []*objectSDK.Range) {
|
||||||
func (p *RangeHashPrm) SetHashGenerator(v func() hash.Hash) {
|
func (p *RangeHashPrm) SetHashGenerator(v func() hash.Hash) {
|
||||||
p.hashGen = v
|
p.hashGen = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetCommonParameters sets common parameters of the operation.
|
||||||
|
func (p *commonPrm) SetCommonParameters(common *util.CommonPrm) {
|
||||||
|
p.common = common
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||||
objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object"
|
objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object"
|
||||||
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
|
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/nspcc-dev/tzhash/tz"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
@ -33,6 +34,9 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre
|
||||||
p.WithRawFlag(body.GetRaw())
|
p.WithRawFlag(body.GetRaw())
|
||||||
p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...)
|
p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...)
|
||||||
p.SetObjectWriter(&streamObjectWriter{stream})
|
p.SetObjectWriter(&streamObjectWriter{stream})
|
||||||
|
p.SetCommonParameters(new(util.CommonPrm).
|
||||||
|
WithLocalOnly(meta.GetTTL() <= 1),
|
||||||
|
)
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
@ -54,6 +58,7 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get
|
||||||
p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...)
|
p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...)
|
||||||
p.SetChunkWriter(&streamObjectRangeWriter{stream})
|
p.SetChunkWriter(&streamObjectRangeWriter{stream})
|
||||||
p.SetRange(object.NewRangeFromV2(body.GetRange()))
|
p.SetRange(object.NewRangeFromV2(body.GetRange()))
|
||||||
|
p.SetCommonParameters(commonParameters(meta))
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
@ -72,6 +77,7 @@ func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.Ran
|
||||||
body := req.GetBody()
|
body := req.GetBody()
|
||||||
p.WithAddress(object.NewAddressFromV2(body.GetAddress()))
|
p.WithAddress(object.NewAddressFromV2(body.GetAddress()))
|
||||||
p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...)
|
p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...)
|
||||||
|
p.SetCommonParameters(commonParameters(meta))
|
||||||
|
|
||||||
rngsV2 := body.GetRanges()
|
rngsV2 := body.GetRanges()
|
||||||
rngs := make([]*object.Range, 0, len(rngsV2))
|
rngs := make([]*object.Range, 0, len(rngsV2))
|
||||||
|
@ -117,6 +123,11 @@ func remoteCallOptionsFromMeta(meta *session.RequestMetaHeader) []client.CallOpt
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func commonParameters(meta *session.RequestMetaHeader) *util.CommonPrm {
|
||||||
|
return new(util.CommonPrm).
|
||||||
|
WithLocalOnly(meta.GetTTL() <= 1)
|
||||||
|
}
|
||||||
|
|
||||||
func splitInfoResponse(info *object.SplitInfo) *objectV2.GetResponse {
|
func splitInfoResponse(info *object.SplitInfo) *objectV2.GetResponse {
|
||||||
resp := new(objectV2.GetResponse)
|
resp := new(objectV2.GetResponse)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue