Update RDB.ForwardIfReady to forward to group if groupKey is specified

This commit is contained in:
Ken Hibino
2022-03-06 05:45:33 -08:00
parent f17c157b0f
commit 61854ea1dc
3 changed files with 195 additions and 19 deletions

View File

@@ -205,9 +205,14 @@ func UniqueKey(qname, tasktype string, payload []byte) string {
return fmt.Sprintf("%sunique:%s:%s", QueueKeyPrefix(qname), tasktype, hex.EncodeToString(checksum[:]))
}
// GroupKeyPrefix returns a prefix for group key.
func GroupKeyPrefix(qname string) string {
return fmt.Sprintf("%sg:", QueueKeyPrefix(qname))
}
// GroupKey returns a redis key used to group tasks belong in the same group.
func GroupKey(qname, gkey string) string {
return fmt.Sprintf("%sg:%s", QueueKeyPrefix(qname), gkey)
return fmt.Sprintf("%s%s", GroupKeyPrefix(qname), gkey)
}
// AllGroups return a redis key used to store all group keys used in a given queue.