mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-26 07:42:17 +08:00
Add base.LeaseKey helper function
This commit is contained in:
parent
5490d2c625
commit
852af7abd1
@ -141,6 +141,11 @@ 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))
|
||||
}
|
||||
|
||||
func CompletedKey(qname string) string {
|
||||
return fmt.Sprintf("%scompleted", QueueKeyPrefix(qname))
|
||||
}
|
||||
|
@ -88,6 +88,23 @@ func TestDeadlinesKey(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLeaseKey(t *testing.T) {
|
||||
tests := []struct {
|
||||
qname string
|
||||
want string
|
||||
}{
|
||||
{"default", "asynq:{default}:lease"},
|
||||
{"custom", "asynq:{custom}:lease"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
got := LeaseKey(tc.qname)
|
||||
if got != tc.want {
|
||||
t.Errorf("LeaseKey(%q) = %q, want %q", tc.qname, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestScheduledKey(t *testing.T) {
|
||||
tests := []struct {
|
||||
qname string
|
||||
|
Loading…
Reference in New Issue
Block a user