[#52] services/object: Implement Get service

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-26 10:54:03 +03:00 committed by Alex Vanin
parent 3880315a3f
commit bf2c33d7a9
6 changed files with 227 additions and 0 deletions

View file

@ -0,0 +1,26 @@
package getsvc
import (
rangesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/range"
"github.com/pkg/errors"
)
type Streamer struct {
headSent bool
rngRes *rangesvc.Result
}
func (p *Streamer) Recv() (interface{}, error) {
if !p.headSent {
p.headSent = true
return p.rngRes.Head(), nil
}
rngResp, err := p.rngRes.Stream().Recv()
if err != nil {
return nil, errors.Wrapf(err, "(%T) could not receive range response", p)
}
return rngResp.PayloadChunk(), nil
}