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:
13
rdb.go
13
rdb.go
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user