forked from TrueCloudLab/frostfs-node
[#52] services/object: Implement Get service
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
3880315a3f
commit
bf2c33d7a9
6 changed files with 227 additions and 0 deletions
26
pkg/services/object/get/streamer.go
Normal file
26
pkg/services/object/get/streamer.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue