diff --git a/internal/asynqtest/asynqtest.go b/internal/asynqtest/asynqtest.go index 7820d91..46ea859 100644 --- a/internal/asynqtest/asynqtest.go +++ b/internal/asynqtest/asynqtest.go @@ -231,13 +231,6 @@ func SeedArchivedQueue(tb testing.TB, r redis.UniversalClient, entries []base.Z, seedRedisZSet(tb, r, base.ArchivedKey(qname), entries, base.TaskStateArchived) } -// SeedDeadlines initializes the deadlines set with the given entries. -func SeedDeadlines(tb testing.TB, r redis.UniversalClient, entries []base.Z, qname string) { - tb.Helper() - r.SAdd(context.Background(), base.AllQueues, qname) - seedRedisZSet(tb, r, base.DeadlinesKey(qname), entries, base.TaskStateActive) -} - // SeedLease initializes the lease set with the given entries. func SeedLease(tb testing.TB, r redis.UniversalClient, entries []base.Z, qname string) { tb.Helper() @@ -294,14 +287,6 @@ func SeedAllArchivedQueues(tb testing.TB, r redis.UniversalClient, archived map[ } } -// SeedAllDeadlines initializes all of the deadlines with the given entries. -func SeedAllDeadlines(tb testing.TB, r redis.UniversalClient, deadlines map[string][]base.Z) { - tb.Helper() - for q, entries := range deadlines { - SeedDeadlines(tb, r, entries, q) - } -} - // SeedAllLease initializes all of the lease sets with the given entries. func SeedAllLease(tb testing.TB, r redis.UniversalClient, lease map[string][]base.Z) { tb.Helper() @@ -330,8 +315,6 @@ func seedRedisList(tb testing.TB, c redis.UniversalClient, key string, data := map[string]interface{}{ "msg": encoded, "state": state.String(), - "timeout": msg.Timeout, - "deadline": msg.Deadline, "unique_key": msg.UniqueKey, } if err := c.HSet(context.Background(), key, data).Err(); err != nil { @@ -360,8 +343,6 @@ func seedRedisZSet(tb testing.TB, c redis.UniversalClient, key string, data := map[string]interface{}{ "msg": encoded, "state": state.String(), - "timeout": msg.Timeout, - "deadline": msg.Deadline, "unique_key": msg.UniqueKey, } if err := c.HSet(context.Background(), key, data).Err(); err != nil { @@ -439,13 +420,6 @@ func GetArchivedEntries(tb testing.TB, r redis.UniversalClient, qname string) [] return getMessagesFromZSetWithScores(tb, r, qname, base.ArchivedKey, base.TaskStateArchived) } -// GetDeadlinesEntries returns all task messages and its score in the deadlines set for the given queue. -// It also asserts the state field of the task. -func GetDeadlinesEntries(tb testing.TB, r redis.UniversalClient, qname string) []base.Z { - tb.Helper() - return getMessagesFromZSetWithScores(tb, r, qname, base.DeadlinesKey, base.TaskStateActive) -} - // GetLeaseEntries returns all task IDs and its score in the lease set for the given queue. // It also asserts the state field of the task. func GetLeaseEntries(tb testing.TB, r redis.UniversalClient, qname string) []base.Z { diff --git a/internal/base/base.go b/internal/base/base.go index ce41fcb..b4ed2ed 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -137,11 +137,6 @@ func ArchivedKey(qname string) string { return fmt.Sprintf("%sarchived", QueueKeyPrefix(qname)) } -// DeadlinesKey returns a redis key for the deadlines. -func DeadlinesKey(qname string) string { - return fmt.Sprintf("%sdeadlines", QueueKeyPrefix(qname)) -} - // LeaseKey returns a redis key for the lease. func LeaseKey(qname string) string { return fmt.Sprintf("%slease", QueueKeyPrefix(qname)) diff --git a/internal/base/base_test.go b/internal/base/base_test.go index 075e3a0..27bc9af 100644 --- a/internal/base/base_test.go +++ b/internal/base/base_test.go @@ -72,23 +72,6 @@ func TestActiveKey(t *testing.T) { } } -func TestDeadlinesKey(t *testing.T) { - tests := []struct { - qname string - want string - }{ - {"default", "asynq:{default}:deadlines"}, - {"custom", "asynq:{custom}:deadlines"}, - } - - for _, tc := range tests { - got := DeadlinesKey(tc.qname) - if got != tc.want { - t.Errorf("DeadlinesKey(%q) = %q, want %q", tc.qname, got, tc.want) - } - } -} - func TestLeaseKey(t *testing.T) { tests := []struct { qname string diff --git a/internal/rdb/benchmark_test.go b/internal/rdb/benchmark_test.go index 011d06d..8d7dfae 100644 --- a/internal/rdb/benchmark_test.go +++ b/internal/rdb/benchmark_test.go @@ -163,7 +163,7 @@ func BenchmarkDone(b *testing.B) { b.StopTimer() asynqtest.FlushDB(b, r.client) asynqtest.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName) - asynqtest.SeedDeadlines(b, r.client, zs, base.DefaultQueueName) + asynqtest.SeedLease(b, r.client, zs, base.DefaultQueueName) b.StartTimer() if err := r.Done(ctx, msgs[0]); err != nil { @@ -190,7 +190,7 @@ func BenchmarkRetry(b *testing.B) { b.StopTimer() asynqtest.FlushDB(b, r.client) asynqtest.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName) - asynqtest.SeedDeadlines(b, r.client, zs, base.DefaultQueueName) + asynqtest.SeedLease(b, r.client, zs, base.DefaultQueueName) b.StartTimer() if err := r.Retry(ctx, msgs[0], time.Now().Add(1*time.Minute), "error", true /*isFailure*/); err != nil { @@ -217,7 +217,7 @@ func BenchmarkArchive(b *testing.B) { b.StopTimer() asynqtest.FlushDB(b, r.client) asynqtest.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName) - asynqtest.SeedDeadlines(b, r.client, zs, base.DefaultQueueName) + asynqtest.SeedLease(b, r.client, zs, base.DefaultQueueName) b.StartTimer() if err := r.Archive(ctx, msgs[0], "error"); err != nil { @@ -244,7 +244,7 @@ func BenchmarkRequeue(b *testing.B) { b.StopTimer() asynqtest.FlushDB(b, r.client) asynqtest.SeedActiveQueue(b, r.client, msgs, base.DefaultQueueName) - asynqtest.SeedDeadlines(b, r.client, zs, base.DefaultQueueName) + asynqtest.SeedLease(b, r.client, zs, base.DefaultQueueName) b.StartTimer() if err := r.Requeue(ctx, msgs[0]); err != nil { diff --git a/internal/rdb/inspect.go b/internal/rdb/inspect.go index 5f70e61..2143421 100644 --- a/internal/rdb/inspect.go +++ b/internal/rdb/inspect.go @@ -1387,7 +1387,7 @@ func (r *RDB) DeleteAllPendingTasks(qname string) (int64, error) { // KEYS[3] -> asynq:{}:scheduled // KEYS[4] -> asynq:{}:retry // KEYS[5] -> asynq:{}:archived -// KEYS[6] -> asynq:{}:deadlines +// KEYS[6] -> asynq:{}:lease // -- // ARGV[1] -> task key prefix // @@ -1447,7 +1447,7 @@ return 1`) // KEYS[3] -> asynq:{}:scheduled // KEYS[4] -> asynq:{}:retry // KEYS[5] -> asynq:{}:archived -// KEYS[6] -> asynq:{}:deadlines +// KEYS[6] -> asynq:{}:lease // -- // ARGV[1] -> task key prefix // @@ -1516,7 +1516,7 @@ func (r *RDB) RemoveQueue(qname string, force bool) error { base.ScheduledKey(qname), base.RetryKey(qname), base.ArchivedKey(qname), - base.DeadlinesKey(qname), + base.LeaseKey(qname), } res, err := script.Run(context.Background(), r.client, keys, base.TaskKeyPrefix(qname)).Result() if err != nil { diff --git a/internal/rdb/inspect_test.go b/internal/rdb/inspect_test.go index ca9e2cf..0a99f37 100644 --- a/internal/rdb/inspect_test.go +++ b/internal/rdb/inspect_test.go @@ -4036,7 +4036,7 @@ func TestRemoveQueue(t *testing.T) { keys := []string{ base.PendingKey(tc.qname), base.ActiveKey(tc.qname), - base.DeadlinesKey(tc.qname), + base.LeaseKey(tc.qname), base.ScheduledKey(tc.qname), base.RetryKey(tc.qname), base.ArchivedKey(tc.qname),