common

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRetryConfig = RetryConfig{
	MaxAttempts:       5,
	InitialBackoff:    200 * time.Millisecond,
	MaxBackoff:        5 * time.Second,
	BackoffMultiplier: 2.0,
}

Functions

func Paginate added in v0.6.0

func Paginate[Item any](
	ctx context.Context,
	fetch func(ctx context.Context, token *string) (items []Item, next *string, err error),
) ([]Item, error)

Paginate calls fetch with the previous response's next token until the returned token is nil or empty. Returned items from each page are appended in order. fetch is responsible for any per-page retry/error formatting.

func WithRetry

func WithRetry[T any](ctx context.Context, cfg RetryConfig, fn func(context.Context) (T, error)) (T, error)

WithRetry runs fn with exponential backoff respecting context cancellation.

Types

type RetryConfig

type RetryConfig struct {
	MaxAttempts       int
	InitialBackoff    time.Duration
	MaxBackoff        time.Duration
	BackoffMultiplier float64
}

RetryConfig controls retry behavior for AWS API calls.

Jump to

Keyboard shortcuts

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