nw_ratelimit

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLastErrors                  = 100
	SameErrorThreshold             = 80
	LastErrorRecycleTimeMultiplier = 100
	ShortWait                      = 3 * time.Second
	LongWait                       = 1 * time.Minute
	LongWaitAlertThreshold         = 5 * time.Minute
)
View Source
const (
	RetryActionShortWait = iota
	RetryActionLongWait
	RetryActionAbort
)

Variables

This section is empty.

Functions

func AddError

func AddError(hash, endpoint string, err error) (abort bool)

func SetTestMode

func SetTestMode(enabled bool)

func UpdateRetryAfter

func UpdateRetryAfter(hash, endpoint string, retryAfter time.Time)

func WaitIfRequired

func WaitIfRequired(hash, endpoint string)

Types

type LimitState

type LimitState interface {
	// Add error that happened with request. Blocks operation for retry SLA.
	// When abort == true, recommend abort retry loop if certain threshold exceed by given err.
	AddError(hash, endpoint string, err error) (abort bool)

	// Update retry after, if Rewind-After header present in the response
	UpdateRetryAfter(hash, endpoint string, retryAfter time.Time)

	// Wait if required. Waits for Max(Rewind-After, RetryActionWait).
	WaitIfRequired(hash, endpoint string)
}

Jump to

Keyboard shortcuts

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