bf2c33d7a9
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
26 lines
488 B
Go
26 lines
488 B
Go
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
|
|
}
|