frostfs-node/pkg/services/audit/auditor/exec.go
Dmitrii Stepanov e8d340287f [#222] auditsvc: Refactor audit task
Resolve containedctx linter. Cancel task by listen cancel.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-04-07 17:29:13 +03:00

37 lines
588 B
Go

package auditor
import (
"context"
"fmt"
)
// Execute audits container data.
func (c *Context) Execute(ctx context.Context, onCompleted func()) {
defer onCompleted()
c.init()
checks := []struct {
name string
exec func(context.Context)
}{
{name: "PoR", exec: c.executePoR},
{name: "PoP", exec: c.executePoP},
{name: "PDP", exec: c.executePDP},
}
for i := range checks {
c.log.Debug(fmt.Sprintf("executing %s check...", checks[i].name))
if c.expired(ctx) {
break
}
checks[i].exec(ctx)
if i == len(checks)-1 {
c.complete()
}
}
c.writeReport()
}