2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-25 23:32:17 +08:00

Change the direction of list push/pop operations

This commit is contained in:
Ken Hibino 2019-11-23 08:24:16 -08:00
parent 3fa867b190
commit 76ceb282a9

6
rdb.go
View File

@ -49,7 +49,7 @@ func (r *rdb) push(msg *taskMessage) error {
return fmt.Errorf("command SADD %q %q failed: %v",
allQueues, qname, err)
}
err = r.client.RPush(qname, string(bytes)).Err()
err = r.client.LPush(qname, string(bytes)).Err()
if err != nil {
return fmt.Errorf("command RPUSH %q %q failed: %v",
qname, string(bytes), err)
@ -60,8 +60,8 @@ func (r *rdb) push(msg *taskMessage) error {
// dequeue blocks until there is a taskMessage available to be processed,
// once available, it adds the task to "in progress" set and returns the task.
func (r *rdb) dequeue(timeout time.Duration, keys ...string) (*taskMessage, error) {
// TODO(hibiken): Make BLPOP & SADD atomic.
res, err := r.client.BLPop(timeout, keys...).Result()
// TODO(hibiken): Make BRPOP & SADD atomic.
res, err := r.client.BRPop(timeout, keys...).Result()
if err != nil {
if err != redis.Nil {
return nil, fmt.Errorf("command BLPOP %v %v failed: %v", timeout, keys, err)