[#235] services/object: Implement new GetRange algorithm
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
91d8e0a4de
commit
1d23483828
37 changed files with 703 additions and 1125 deletions
|
@ -23,14 +23,35 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre
|
|||
p.SetPrivateKey(key)
|
||||
|
||||
body := req.GetBody()
|
||||
p.SetAddress(object.NewAddressFromV2(body.GetAddress()))
|
||||
p.SetRaw(body.GetRaw())
|
||||
p.WithAddress(object.NewAddressFromV2(body.GetAddress()))
|
||||
p.WithRawFlag(body.GetRaw())
|
||||
p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...)
|
||||
p.SetObjectWriter(&streamObjectWriter{stream})
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.GetObjectRangeStream) (*getsvc.RangePrm, error) {
|
||||
meta := req.GetMetaHeader()
|
||||
|
||||
key, err := s.keyStorage.GetKey(token.NewSessionTokenFromV2(meta.GetSessionToken()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := new(getsvc.RangePrm)
|
||||
p.SetPrivateKey(key)
|
||||
|
||||
body := req.GetBody()
|
||||
p.WithAddress(object.NewAddressFromV2(body.GetAddress()))
|
||||
p.WithRawFlag(body.GetRaw())
|
||||
p.SetRemoteCallOptions(remoteCallOptionsFromMeta(meta)...)
|
||||
p.SetChunkWriter(&streamObjectRangeWriter{stream})
|
||||
p.SetRange(object.NewRangeFromV2(body.GetRange()))
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// can be shared accross all services
|
||||
func remoteCallOptionsFromMeta(meta *session.RequestMetaHeader) []client.CallOption {
|
||||
xHdrs := meta.GetXHeaders()
|
||||
|
@ -60,3 +81,14 @@ func splitInfoResponse(info *object.SplitInfo) *objectV2.GetResponse {
|
|||
|
||||
return resp
|
||||
}
|
||||
|
||||
func splitInfoRangeResponse(info *object.SplitInfo) *objectV2.GetRangeResponse {
|
||||
resp := new(objectV2.GetRangeResponse)
|
||||
|
||||
body := new(objectV2.GetRangeResponseBody)
|
||||
resp.SetBody(body)
|
||||
|
||||
body.SetRangePart(info.ToV2())
|
||||
|
||||
return resp
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue