[#255] ir/audit: Make task manager to return number of skipped tasks

Add numeric return from TaskManager.Reset method that shows the number of
canceled tasks. This values will be used for assessment of the progress of
the audit.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-22 15:34:38 +03:00 committed by Alex Vanin
parent 03e3afb0e8
commit 2ebcbe70fb
3 changed files with 16 additions and 4 deletions

View file

@ -21,7 +21,13 @@ func (ap *Processor) processStartAudit(epoch uint64) {
log := ap.log.With(zap.Uint64("epoch", epoch)) log := ap.log.With(zap.Uint64("epoch", epoch))
ap.prevAuditCanceler() ap.prevAuditCanceler()
ap.taskManager.Reset()
skipped := ap.taskManager.Reset()
if skipped > 0 {
ap.log.Info("some tasks from previous epoch are skipped",
zap.Int("amount", skipped),
)
}
containers, err := ap.selectContainersToAudit(epoch) containers, err := ap.selectContainersToAudit(epoch)
if err != nil { if err != nil {

View file

@ -30,7 +30,10 @@ type (
TaskManager interface { TaskManager interface {
PushTask(*audit.Task) error PushTask(*audit.Task) error
Reset()
// Must skip all tasks planned for execution and
// return their number.
Reset() int
} }
// Processor of events related with data audit. // Processor of events related with data audit.

View file

@ -1,8 +1,11 @@
package audittask package audittask
// Reset pops all tasks from the queue. // Reset pops all tasks from the queue.
func (m *Manager) Reset() { // Returns amount of popped elements.
for len(m.ch) > 0 { func (m *Manager) Reset() (popped int) {
for ; len(m.ch) > 0; popped++ {
<-m.ch <-m.ch
} }
return
} }