throttling

package
v1.32.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Strategy

type Strategy interface {
	// Delay returns the delay for next request.
	Delay() time.Duration
	// Observe recalculates the next delay based on the feedback.
	Observe(err error)
}

Strategy handles delays based on feedbacks provided

func NewDefaultStrategy

func NewDefaultStrategy(minDelay, maxDelay time.Duration, clock clock.Clock) (Strategy, error)

func NewDynamicStrategy

func NewDynamicStrategy(
	minDelay time.Duration,
	maxDelay time.Duration,
	errorsBeforeIncreasingDelay int,
	successesBeforeDecreasingDelay int,
	successesBeforeResettingDelay int,
	noRequestsTimeoutBeforeDecreasingDelay time.Duration,
	noRequestsTimeoutBeforeResettingDelay time.Duration,
	clock clock.Clock) (Strategy, error)

func NewTwoWayStrategy

func NewTwoWayStrategy(
	minDelay time.Duration,
	maxDelay time.Duration,
	noRequestsTimeoutBeforeDecreasingDelay time.Duration,
	noRequestsTimeoutBeforeResettingDelay time.Duration,
	clock clock.Clock) (Strategy, error)

Jump to

Keyboard shortcuts

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