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
|
@ -15,10 +15,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
)
|
||||
|
||||
// nolint: containedctx
|
||||
type remoteTarget struct {
|
||||
ctx context.Context
|
||||
|
||||
privateKey *ecdsa.PrivateKey
|
||||
|
||||
commonPrm *util.CommonPrm
|
||||
|
@ -51,7 +48,7 @@ func (t *remoteTarget) WriteObject(obj *object.Object, _ objectcore.ContentMeta)
|
|||
return nil
|
||||
}
|
||||
|
||||
func (t *remoteTarget) Close() (*transformer.AccessIdentifiers, error) {
|
||||
func (t *remoteTarget) Close(ctx context.Context) (*transformer.AccessIdentifiers, error) {
|
||||
c, err := t.clientConstructor.Get(t.nodeInfo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("(%T) could not create SDK client %s: %w", t, t.nodeInfo, err)
|
||||
|
@ -59,7 +56,7 @@ func (t *remoteTarget) Close() (*transformer.AccessIdentifiers, error) {
|
|||
|
||||
var prm internalclient.PutObjectPrm
|
||||
|
||||
prm.SetContext(t.ctx)
|
||||
prm.SetContext(ctx)
|
||||
prm.SetClient(c)
|
||||
prm.SetPrivateKey(t.privateKey)
|
||||
prm.SetSessionToken(t.commonPrm.SessionToken())
|
||||
|
@ -110,7 +107,6 @@ func (s *RemoteSender) PutObject(ctx context.Context, p *RemotePutPrm) error {
|
|||
}
|
||||
|
||||
t := &remoteTarget{
|
||||
ctx: ctx,
|
||||
privateKey: key,
|
||||
clientConstructor: s.clientConstructor,
|
||||
}
|
||||
|
@ -122,7 +118,7 @@ func (s *RemoteSender) PutObject(ctx context.Context, p *RemotePutPrm) error {
|
|||
|
||||
if err := t.WriteObject(p.obj, objectcore.ContentMeta{}); err != nil {
|
||||
return fmt.Errorf("(%T) could not send object header: %w", s, err)
|
||||
} else if _, err := t.Close(); err != nil {
|
||||
} else if _, err := t.Close(ctx); err != nil {
|
||||
return fmt.Errorf("(%T) could not send object: %w", s, err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue