From f2284be43d53405f70ebd92a7351f5c8a4264ef6 Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Mon, 26 Apr 2021 07:07:12 -0700 Subject: [PATCH] Update RDB.Dequeue with task state --- internal/asynqtest/asynqtest.go | 2 +- internal/rdb/rdb.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/asynqtest/asynqtest.go b/internal/asynqtest/asynqtest.go index 3eb3076..a3d1452 100644 --- a/internal/asynqtest/asynqtest.go +++ b/internal/asynqtest/asynqtest.go @@ -423,7 +423,7 @@ func getMessagesFromZSetWithScores(tb testing.TB, r redis.UniversalClient, msg := r.HGet(taskKey, "msg").Val() res = append(res, base.Z{Message: MustUnmarshal(tb, msg), Score: int64(z.Score)}) if gotState := r.HGet(taskKey, "state").Val(); gotState != state { - tb.Errorf("task (id=%q) is in state %q, want %q", taskID, gotState, state) + tb.Errorf("task (id=%q) is in %q state, want %q", taskID, gotState, state) } } return res diff --git a/internal/rdb/rdb.go b/internal/rdb/rdb.go index fbb1825..01c63ee 100644 --- a/internal/rdb/rdb.go +++ b/internal/rdb/rdb.go @@ -175,6 +175,7 @@ if redis.call("EXISTS", KEYS[2]) == 0 then local id = redis.call("RPOPLPUSH", KEYS[1], KEYS[3]) if id then local key = ARGV[2] .. id + redis.call("HSET", key, "state", "active") local data = redis.call("HMGET", key, "msg", "timeout", "deadline") local msg = data[1] local timeout = tonumber(data[2])