[#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

@ -11,6 +11,17 @@ import (
// Prm groups parameters of Get service call.
type Prm struct {
commonPrm
}
// RangePrm groups parameters of GetRange service call.
type RangePrm struct {
commonPrm
rng *objectSDK.Range
}
type commonPrm struct {
objWriter ObjectWriter
// TODO: replace key and callOpts to CommonPrm
@ -20,16 +31,19 @@ type Prm struct {
common *util.CommonPrm
// TODO: use parameters from NeoFS SDK
addr *objectSDK.Address
client.GetObjectParams
}
raw bool
// ChunkWriter is an interface of target component
// to write payload chunk.
type ChunkWriter interface {
WriteChunk([]byte) error
}
// ObjectWriter is an interface of target component to write object.
type ObjectWriter interface {
WriteHeader(*object.Object) error
WriteChunk([]byte) error
ChunkWriter
}
// SetObjectWriter sets target component to write the object.
@ -38,22 +52,23 @@ func (p *Prm) SetObjectWriter(w ObjectWriter) {
}
// SetPrivateKey sets private key to use during execution.
func (p *Prm) SetPrivateKey(key *ecdsa.PrivateKey) {
func (p *commonPrm) SetPrivateKey(key *ecdsa.PrivateKey) {
p.key = key
}
// SetRemoteCallOptions sets call options remote remote client calls.
func (p *Prm) SetRemoteCallOptions(opts ...client.CallOption) {
func (p *commonPrm) SetRemoteCallOptions(opts ...client.CallOption) {
p.callOpts = opts
}
// SetAddress sets address of the requested object.
func (p *Prm) SetAddress(addr *objectSDK.Address) {
p.addr = addr
// SetObjectWriter sets target component to write the object payload range.
func (p *RangePrm) SetChunkWriter(w ChunkWriter) {
p.objWriter = &rangeWriter{
chunkWriter: w,
}
}
// SetRaw sets raw flag. If flag is set,
// object assembling will not be undertaken.
func (p *Prm) SetRaw(raw bool) {
p.raw = raw
// SetRange sets range of the requested payload data.
func (p *RangePrm) SetRange(rng *objectSDK.Range) {
p.rng = rng
}