From ece6c820e70d8a58ab0a20f72c45708c8d411958 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Mon, 3 Apr 2023 15:40:52 +0300 Subject: [PATCH] [#199] putsvc: Refactor streamer initialization Resolve funlen linter for initTarget method Signed-off-by: Dmitrii Stepanov --- pkg/services/object/put/streamer.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index 678cff57..fed161e0 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -51,7 +51,6 @@ func (p *Streamer) MaxObjectSize() uint64 { return p.maxPayloadSz } -// nolint: funlen func (p *Streamer) initTarget(prm *PutInitPrm) error { // prevent re-calling if p.target != nil { @@ -69,19 +68,26 @@ func (p *Streamer) initTarget(prm *PutInitPrm) error { } if prm.hdr.Signature() != nil { - p.relay = prm.relay + return p.initUntrustedTarget(prm) + } + return p.initTrustedTarget(prm) +} - // prepare untrusted-Put object target - p.target = &validatingTarget{ - nextTarget: p.newCommonTarget(prm), - fmt: p.fmtValidator, +func (p *Streamer) initUntrustedTarget(prm *PutInitPrm) error { + p.relay = prm.relay - maxPayloadSz: p.maxPayloadSz, - } + // prepare untrusted-Put object target + p.target = &validatingTarget{ + nextTarget: p.newCommonTarget(prm), + fmt: p.fmtValidator, - return nil + maxPayloadSz: p.maxPayloadSz, } + return nil +} + +func (p *Streamer) initTrustedTarget(prm *PutInitPrm) error { sToken := prm.common.SessionToken() // prepare trusted-Put object target