cic-custodial/internal/tasker/task/utils.go
Mohammed Sohail ad58d1da47
feat: add lock retry strategy
* previouly we relied on the task being re-queued which generally reduces the throughput of tasks
2023-03-14 16:02:25 +00:00

22 lines
434 B
Go

package task
import (
"time"
"github.com/bsm/redislock"
)
const (
lockPrefix = "lock:"
lockRetryDelay = 25 * time.Millisecond
)
// lockRetry will at most try to obtain the lock 20 times within ~0.5s.
// it is expected to prevent immidiate requeue of the task at the expense of more redis calls.
func lockRetry() redislock.RetryStrategy {
return redislock.LimitRetry(
redislock.LinearBackoff(lockRetryDelay),
20,
)
}