-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
rate_limiters.go
30 lines (22 loc) · 1019 Bytes
/
rate_limiters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package controller
import (
"time"
"k8s.io/client-go/util/workqueue"
"github.com/argoproj/argo-workflows/v3/util/env"
)
type fixedItemIntervalRateLimiter struct{}
func (r *fixedItemIntervalRateLimiter) When(interface{}) time.Duration {
// We need to rate limit a minimum 1s, otherwise informers are unlikely to be upto date
// and we'll operate on an out of date version of a workflow.
// Under high load, the informer can get many seconds behind. Increasing this to 30s
// would be sensible for some users.
// Higher values mean that workflows with many short running (<20s) nodes do not progress as quickly.
// So some users may wish to have this as low as 2s.
// The default of 10s provides a balance more most users.
return env.LookupEnvDurationOr("DEFAULT_REQUEUE_TIME", 10*time.Second)
}
func (r *fixedItemIntervalRateLimiter) Forget(interface{}) {}
func (r *fixedItemIntervalRateLimiter) NumRequeues(interface{}) int {
return 1
}
var _ workqueue.RateLimiter = &fixedItemIntervalRateLimiter{}