Documentation
¶
Index ¶
- type EncapsulatingRateLimiter
- func (c *EncapsulatingRateLimiter[K]) Add(key K, rl workqueue.TypedRateLimiter[reconcile.Request], req reconcile.Request)
- func (c *EncapsulatingRateLimiter[K]) Forget(req reconcile.Request)
- func (c *EncapsulatingRateLimiter[K]) NumRequeues(req reconcile.Request) int
- func (c *EncapsulatingRateLimiter[K]) Remove(req reconcile.Request)
- func (c *EncapsulatingRateLimiter[K]) When(req reconcile.Request) time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EncapsulatingRateLimiter ¶
type EncapsulatingRateLimiter[K comparable] struct { // contains filtered or unexported fields }
EncapsulatingRateLimiter is a workqueue.TypedRateLimiter[reconcile.Request] that wraps a default rate limiter and lets callers override it on a per-request basis. Requests are bucketed under a caller-supplied key of type K; all requests sharing a key share the same backing rate limiter and therefore share its retry state. A request with no override is rate limited by the default rate limiter supplied to NewEncapsulatingRateLimiter.
EncapsulatingRateLimiter is safe for concurrent use.
func NewEncapsulatingRateLimiter ¶
func NewEncapsulatingRateLimiter[K comparable](defaultRateLimiter workqueue.TypedRateLimiter[reconcile.Request]) *EncapsulatingRateLimiter[K]
NewEncapsulatingRateLimiter returns an EncapsulatingRateLimiter that delegates to defaultRateLimiter for any request that has not had a per-key override registered via Add.
func (*EncapsulatingRateLimiter[K]) Add ¶
func (c *EncapsulatingRateLimiter[K]) Add(key K, rl workqueue.TypedRateLimiter[reconcile.Request], req reconcile.Request)
Add registers the specified rate limiter with this EncapsulatingRateLimiter using the specified key and associates the given request with it. If there already exists a rate limiter for the given key, the existing rate limiter's state is preserved. rl is only associated with the given key if a rate limiter for that key does not already exist.
func (*EncapsulatingRateLimiter[K]) Forget ¶
func (c *EncapsulatingRateLimiter[K]) Forget(req reconcile.Request)
Forget clears the retry state for req on its associated rate limiter, or on the default rate limiter if no override has been registered for req. It does not remove req from the registry; use Remove for that.
func (*EncapsulatingRateLimiter[K]) NumRequeues ¶
func (c *EncapsulatingRateLimiter[K]) NumRequeues(req reconcile.Request) int
NumRequeues returns the number of times req has been requeued, as reported by the rate limiter associated with req via Add, or by the default rate limiter if no override has been registered for req.
func (*EncapsulatingRateLimiter[K]) Remove ¶
func (c *EncapsulatingRateLimiter[K]) Remove(req reconcile.Request)
Remove removes the given request from its associated rate limiter. If the rate limiter has no remaining associated requests with it, it's removed from the registry.
func (*EncapsulatingRateLimiter[K]) When ¶
func (c *EncapsulatingRateLimiter[K]) When(req reconcile.Request) time.Duration
When returns the delay before req should be retried. It is delegated to the rate limiter associated with req via Add, or to the default rate limiter if no override has been registered for req.