forked from TrueCloudLab/frostfs-node
[#222] auditsvc: Refactor audit task
Resolve containedctx linter. Cancel task by listen cancel. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
3dbff0a478
commit
e8d340287f
10 changed files with 66 additions and 58 deletions
|
@ -1,8 +1,6 @@
|
|||
package audit
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/storagegroup"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
|
@ -10,11 +8,10 @@ import (
|
|||
)
|
||||
|
||||
// Task groups groups the container audit parameters.
|
||||
// nolint: containedctx
|
||||
type Task struct {
|
||||
reporter Reporter
|
||||
cancelCh <-chan struct{}
|
||||
|
||||
auditContext context.Context
|
||||
reporter Reporter
|
||||
|
||||
idCnr cid.ID
|
||||
|
||||
|
@ -41,18 +38,15 @@ func (t *Task) Reporter() Reporter {
|
|||
return t.reporter
|
||||
}
|
||||
|
||||
// WithAuditContext sets context of the audit of the current epoch.
|
||||
func (t *Task) WithAuditContext(ctx context.Context) *Task {
|
||||
if t != nil {
|
||||
t.auditContext = ctx
|
||||
func (t *Task) WithCancelChannel(ch <-chan struct{}) *Task {
|
||||
if ch != nil {
|
||||
t.cancelCh = ch
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
// AuditContext returns context of the audit of the current epoch.
|
||||
func (t *Task) AuditContext() context.Context {
|
||||
return t.auditContext
|
||||
func (t *Task) CancelChannel() <-chan struct{} {
|
||||
return t.cancelCh
|
||||
}
|
||||
|
||||
// WithContainerID sets identifier of the container under audit.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue