[#255] services/audit: Skip all tasks from previous epoch in audit processor

Implement Reset method on audit task manager that cleans task queue.
Extended TaskManager interface with Reset method on IR side. Call Reset
method in audit processor before new audit start.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-22 14:27:39 +03:00 committed by Alex Vanin
parent 33804e024d
commit 76d4e53ea0
3 changed files with 10 additions and 0 deletions

View file

@ -21,6 +21,7 @@ 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()
containers, err := ap.selectContainersToAudit(epoch) containers, err := ap.selectContainersToAudit(epoch)
if err != nil { if err != nil {

View file

@ -30,6 +30,7 @@ type (
TaskManager interface { TaskManager interface {
PushTask(*audit.Task) error PushTask(*audit.Task) error
Reset()
} }
// Processor of events related with data audit. // Processor of events related with data audit.

View file

@ -0,0 +1,8 @@
package audittask
// Reset pops all tasks from the queue.
func (m *Manager) Reset() {
for len(m.ch) > 0 {
<-m.ch
}
}