[#208] deletesvc: Resolve containedctx linter

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-04-04 12:45:59 +03:00
parent 4941926c9d
commit 5f2a1531fe
5 changed files with 46 additions and 49 deletions

View file

@ -18,12 +18,9 @@ type statusError struct {
err error
}
// nolint: containedctx
type execCtx struct {
svc *Service
ctx context.Context
prm Prm
statusError
@ -52,10 +49,6 @@ func (exec *execCtx) setLogger(l *logger.Logger) {
)}
}
func (exec execCtx) context() context.Context {
return exec.ctx
}
func (exec execCtx) isLocal() bool {
return exec.prm.common.LocalOnly()
}
@ -80,10 +73,10 @@ func (exec *execCtx) newAddress(id oid.ID) oid.Address {
return a
}
func (exec *execCtx) formSplitInfo() bool {
func (exec *execCtx) formSplitInfo(ctx context.Context) bool {
var err error
exec.splitInfo, err = exec.svc.header.splitInfo(exec)
exec.splitInfo, err = exec.svc.header.splitInfo(ctx, exec)
switch {
default:
@ -101,29 +94,29 @@ func (exec *execCtx) formSplitInfo() bool {
return err == nil
}
func (exec *execCtx) collectMembers() (ok bool) {
func (exec *execCtx) collectMembers(ctx context.Context) (ok bool) {
if exec.splitInfo == nil {
exec.log.Debug("no split info, object is PHY")
return true
}
if _, withLink := exec.splitInfo.Link(); withLink {
ok = exec.collectChildren()
ok = exec.collectChildren(ctx)
}
if !ok {
if _, withLast := exec.splitInfo.LastPart(); withLast {
ok = exec.collectChain()
ok = exec.collectChain(ctx)
if !ok {
return
}
}
} // may be fail if neither right nor linking ID is set?
return exec.supplementBySplitID()
return exec.supplementBySplitID(ctx)
}
func (exec *execCtx) collectChain() bool {
func (exec *execCtx) collectChain(ctx context.Context) bool {
var chain []oid.ID
exec.log.Debug("assembling chain...")
@ -131,7 +124,7 @@ func (exec *execCtx) collectChain() bool {
for prev, withPrev := exec.splitInfo.LastPart(); withPrev; {
chain = append(chain, prev)
p, err := exec.svc.header.previous(exec, prev)
p, err := exec.svc.header.previous(ctx, exec, prev)
switch {
default:
@ -160,10 +153,10 @@ func (exec *execCtx) collectChain() bool {
return true
}
func (exec *execCtx) collectChildren() bool {
func (exec *execCtx) collectChildren(ctx context.Context) bool {
exec.log.Debug("collecting children...")
children, err := exec.svc.header.children(exec)
children, err := exec.svc.header.children(ctx, exec)
switch {
default:
@ -187,10 +180,10 @@ func (exec *execCtx) collectChildren() bool {
}
}
func (exec *execCtx) supplementBySplitID() bool {
func (exec *execCtx) supplementBySplitID(ctx context.Context) bool {
exec.log.Debug("supplement by split ID")
chain, err := exec.svc.searcher.splitMembers(exec)
chain, err := exec.svc.searcher.splitMembers(ctx, exec)
switch {
default:
@ -264,8 +257,8 @@ func (exec *execCtx) initTombstoneObject() bool {
return true
}
func (exec *execCtx) saveTombstone() bool {
id, err := exec.svc.placer.put(exec)
func (exec *execCtx) saveTombstone(ctx context.Context) bool {
id, err := exec.svc.placer.put(ctx, exec)
switch {
default: