feat: dlq for dispatcher queues (#2600)

* feat: dlq for dispatcher queues

* reduce dispatcher message ttl to 20 seconds

* rename dispatcher queue for clarity

* add error logs when dead lettering

* address comment
This commit is contained in:
abelanger5
2025-12-04 14:19:01 -05:00
committed by GitHub
parent cf18b31218
commit 9dabe7d902
9 changed files with 333 additions and 45 deletions
+11 -2
View File
@@ -1,6 +1,7 @@
package queueutils
import (
"math"
"math/rand"
"time"
)
@@ -13,9 +14,17 @@ func SleepWithExponentialBackoff(base, max time.Duration, retryCount int) { // n
retryCount = 0
}
// prevent overflow
pow := time.Duration(math.MaxInt64)
if retryCount < 63 {
pow = 1 << retryCount
}
// Calculate exponential backoff
backoff := base * (1 << retryCount)
if backoff > max {
backoff := base * pow
// if backoff / pow does not recover base, we've overflowed
if backoff > max || backoff/pow != base {
backoff = max
}