ratex

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecRetryable

func ExecRetryable[R any](ctx context.Context, closure func(ctx context.Context) (R, error), params RetryParams) (R, error)

func RateLimit

func RateLimit(ctx context.Context, params RateLimitParams) (*rate.Limiter, error)

Types

type RateLimitParams

type RateLimitParams struct {
	RateLimiter *rate.Limiter // can be nil to create a new rate limiter

	// Attempt represents the current attempt, starting at 1. This will increment for each (re)try
	Attempt int

	MinDuration time.Duration
	MaxDuration time.Duration
}

type RetryParams

type RetryParams struct {
	ShouldRetry func(err error) bool
	MaxAttempts int
	MinDuration time.Duration
	MaxDuration time.Duration
}

Jump to

Keyboard shortcuts

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