[#235] services/object: Implement new GetRange algorithm

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-07 20:49:47 +03:00 committed by Alex Vanin
parent 91d8e0a4de
commit 1d23483828
37 changed files with 703 additions and 1125 deletions

View file

@ -10,6 +10,10 @@ type streamObjectWriter struct {
objectSvc.GetObjectStream
}
type streamObjectRangeWriter struct {
objectSvc.GetObjectRangeStream
}
func (s *streamObjectWriter) WriteHeader(obj *object.Object) error {
p := new(objectV2.GetObjectPartInit)
@ -38,3 +42,21 @@ func newResponse(p objectV2.GetObjectPart) *objectV2.GetResponse {
return r
}
func (s *streamObjectRangeWriter) WriteChunk(chunk []byte) error {
return s.GetObjectRangeStream.Send(newRangeResponse(chunk))
}
func newRangeResponse(p []byte) *objectV2.GetRangeResponse {
r := new(objectV2.GetRangeResponse)
body := new(objectV2.GetRangeResponseBody)
r.SetBody(body)
part := new(objectV2.GetRangePartChunk)
part.SetChunk(p)
body.SetRangePart(part)
return r
}