mirror of
https://github.com/hibiken/asynq.git
synced 2026-02-02 05:46:53 +00:00
Add logic to restore unfinished tasks back into the default queue if
there are any uncompleted tasks
This commit is contained in:
12
processor.go
12
processor.go
@@ -41,6 +41,9 @@ func (p *processor) terminate() {
|
||||
}
|
||||
|
||||
func (p *processor) start() {
|
||||
// NOTE: The call to "restore" needs to complete before starting
|
||||
// the processor goroutine.
|
||||
p.restore()
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
@@ -92,3 +95,12 @@ func (p *processor) exec() {
|
||||
}
|
||||
}(task)
|
||||
}
|
||||
|
||||
// restore moves all tasks from "in-progress" back to queue
|
||||
// to restore all unfinished tasks.
|
||||
func (p *processor) restore() {
|
||||
err := p.rdb.moveAll(inProgress, defaultQueue)
|
||||
if err != nil {
|
||||
log.Printf("[SERVER ERROR] could not move tasks from %q to %q\n", inProgress, defaultQueue)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user