ratelimiter

package
v0.19.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 8 Imported by: 794

Documentation

Overview

Package ratelimiter contains suggested default ratelimiters for Crossplane.

Index

Constants

View Source
const (
	// DefaultProviderRPS is the recommended default average requeues per
	// second tolerated by a Crossplane provider.
	//
	// Deprecated: Use a flag
	DefaultProviderRPS = 1
)

Variables

This section is empty.

Functions

func LimitRESTConfig added in v0.16.0

func LimitRESTConfig(cfg *rest.Config, rps int) *rest.Config

LimitRESTConfig returns a copy of the supplied REST config with rate limits derived from the supplied rate of reconciles per second.

func NewController added in v0.16.0

func NewController() ratelimiter.RateLimiter

NewController returns a rate limiter that takes the maximum delay between the passed rate limiter and a per-item exponential backoff limiter. The exponential backoff limiter has a base delay of 1s and a maximum of 60s.

func NewDefaultManagedRateLimiter deprecated

func NewDefaultManagedRateLimiter(provider ratelimiter.RateLimiter) ratelimiter.RateLimiter

NewDefaultManagedRateLimiter returns a rate limiter that takes the maximum delay between the passed provider and a per-item exponential backoff limiter. The exponential backoff limiter has a base delay of 1s and a maximum of 60s.

Deprecated: Use NewController.

func NewDefaultProviderRateLimiter deprecated

func NewDefaultProviderRateLimiter(rps int) *workqueue.BucketRateLimiter

NewDefaultProviderRateLimiter returns a token bucket rate limiter meant for limiting the number of average total requeues per second for all controllers registered with a controller manager. The bucket size is a linear function of the requeues per second.

Deprecated: Use NewGlobal.

func NewGlobal added in v0.16.0

func NewGlobal(rps int) *workqueue.BucketRateLimiter

NewGlobal returns a token bucket rate limiter meant for limiting the number of average total requeues per second for all controllers registered with a controller manager. The bucket size (i.e. allowed burst) is rps * 10.

Types

type Reconciler added in v0.16.0

type Reconciler struct {
	// contains filtered or unexported fields
}

A Reconciler rate limits an inner, wrapped Reconciler. Requests that are rate limited immediately return RequeueAfter: d without calling the wrapped Reconciler, where d is imposed by the rate limiter.

func NewReconciler added in v0.16.0

func NewReconciler(name string, r reconcile.Reconciler, l ratelimiter.RateLimiter) *Reconciler

NewReconciler wraps the supplied Reconciler, ensuring requests are passed to it no more frequently than the supplied RateLimiter allows. Multiple uniquely named Reconcilers can share the same RateLimiter.

func (*Reconciler) Reconcile added in v0.16.0

func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)

Reconcile the supplied request subject to rate limiting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL