2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-05-05 07:36:25 +08:00

Add logic to restore unfinished tasks back into the default queue if

there are any uncompleted tasks
This commit is contained in:
Ken Hibino
2019-11-23 15:09:50 -08:00
parent 4a327933bd
commit fd80126a67
3 changed files with 71 additions and 12 deletions

13
rdb.go
View File

@@ -171,3 +171,16 @@ func (r *rdb) listQueues() []string {
}
return queues
}
// moveAll moves all tasks from src list to dst list.
func (r *rdb) moveAll(src, dst string) error {
// TODO(hibiken): Lua script
txf := func(tx *redis.Tx) error {
length := tx.LLen(src).Val()
for i := 0; i < int(length); i++ {
tx.RPopLPush(src, dst)
}
return nil
}
return r.client.Watch(txf, src)
}