1e170c3812
Support processing of NetmapEpoch and NetmapLookupDepth X-headers when processing object read operations. Placement for operations Get/Head/GetRange/GetRangeHash/Search is built for the epoch specified in NetmapEpoch X-header (by default latest). Also the specified operations are processed until success is achieved for network maps from the past up to NetmapLookupDepth value. Behavior for default values (zero or missing) left unchanged. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
42 lines
1 KiB
Go
42 lines
1 KiB
Go
package putsvc
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neofs-api-go/v2/object"
|
|
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type streamer struct {
|
|
stream *putsvc.Streamer
|
|
}
|
|
|
|
func (s *streamer) Send(req *object.PutRequest) (err error) {
|
|
switch v := req.GetBody().GetObjectPart().(type) {
|
|
case *object.PutObjectPartInit:
|
|
initPrm, err := toInitPrm(v, req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err = s.stream.Init(initPrm); err != nil {
|
|
err = errors.Wrapf(err, "(%T) could not init object put stream", s)
|
|
}
|
|
case *object.PutObjectPartChunk:
|
|
if err = s.stream.SendChunk(toChunkPrm(v)); err != nil {
|
|
err = errors.Wrapf(err, "(%T) could not send payload chunk", s)
|
|
}
|
|
default:
|
|
err = errors.Errorf("(%T) invalid object put stream part type %T", s, v)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *streamer) CloseAndRecv() (*object.PutResponse, error) {
|
|
resp, err := s.stream.Close()
|
|
if err != nil {
|
|
return nil, errors.Wrapf(err, "(%T) could not object put stream", s)
|
|
}
|
|
|
|
return fromPutResponse(resp), nil
|
|
}
|