ratehandler

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateBackoff

func CalculateBackoff(retry int) time.Duration

CalculateBackoff calculates the next delay for retry with exponential backoff and jitter. The baseDelay is the initial delay duration, which is exponentially increased on each retry. The jitterFactor adds randomness to the delay to avoid simultaneous retries (thundering herd problem). The delay is capped at maxDelay to prevent excessive wait times.

func ParseRateLimitHeaders

func ParseRateLimitHeaders(resp *http.Response, log logger.Logger) time.Duration

ParseRateLimitHeaders parses common rate limit headers and adjusts behavior accordingly. It handles both Retry-After (in seconds or HTTP-date format) and X-RateLimit-Reset headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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