forked from TrueCloudLab/frostfs-node
[#199] putsvc: Refactor put object
Resolve containedctx linter for streamer and remote target Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
cecea8053a
commit
27bdddc48f
24 changed files with 171 additions and 125 deletions
|
@ -16,12 +16,9 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
||||
)
|
||||
|
||||
// nolint: containedctx
|
||||
type Streamer struct {
|
||||
*cfg
|
||||
|
||||
ctx context.Context
|
||||
|
||||
sessionKey *ecdsa.PrivateKey
|
||||
|
||||
target transformer.ObjectTarget
|
||||
|
@ -232,7 +229,6 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget {
|
|||
}
|
||||
|
||||
rt := &remoteTarget{
|
||||
ctx: p.ctx,
|
||||
privateKey: p.sessionKey,
|
||||
commonPrm: prm.common,
|
||||
clientConstructor: p.clientConstructor,
|
||||
|
@ -250,24 +246,24 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget {
|
|||
}
|
||||
}
|
||||
|
||||
func (p *Streamer) SendChunk(prm *PutChunkPrm) error {
|
||||
func (p *Streamer) SendChunk(ctx context.Context, prm *PutChunkPrm) error {
|
||||
if p.target == nil {
|
||||
return errNotInit
|
||||
}
|
||||
|
||||
if _, err := p.target.Write(prm.chunk); err != nil {
|
||||
if _, err := p.target.Write(ctx, prm.chunk); err != nil {
|
||||
return fmt.Errorf("(%T) could not write payload chunk to target: %w", p, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Streamer) Close() (*PutResponse, error) {
|
||||
func (p *Streamer) Close(ctx context.Context) (*PutResponse, error) {
|
||||
if p.target == nil {
|
||||
return nil, errNotInit
|
||||
}
|
||||
|
||||
ids, err := p.target.Close()
|
||||
ids, err := p.target.Close(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("(%T) could not close object target: %w", p, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue