Documentation
¶
Index ¶
- Constants
- Variables
- func ForEachParallel[T, R any](ctx context.Context, items []T, maxConcurrency int, ...) []R
- func IdempotencyToken() string
- func Paginate[Item any](ctx context.Context, ...) ([]Item, error)
- func WithRetry[T any](ctx context.Context, cfg RetryConfig, fn func(context.Context) (T, error)) (T, error)
- type RetryConfig
- type TTLCache
Constants ¶
const DefaultItemConcurrency = 8
DefaultItemConcurrency bounds per-item AWS describe fan-out (distinct from the user-facing --max-concurrency, which bounds multi-region fan-out).
Variables ¶
var DefaultRetryConfig = RetryConfig{ MaxAttempts: 5, InitialBackoff: 200 * time.Millisecond, MaxBackoff: 5 * time.Second, BackoffMultiplier: 2.0, }
Functions ¶
func ForEachParallel ¶ added in v0.7.0
func ForEachParallel[T, R any](ctx context.Context, items []T, maxConcurrency int, fn func(ctx context.Context, item T) R) []R
ForEachParallel runs fn over items with bounded concurrency and returns the results in input order. fn must be safe to call concurrently; per-item failures should be encoded in R (e.g. a nil pointer) rather than aborting the whole batch, matching the best-effort semantics of list operations.
func IdempotencyToken ¶ added in v0.7.0
func IdempotencyToken() string
IdempotencyToken returns a random token for AWS APIs that accept a ClientRequestToken. Setting it explicitly ONCE per logical operation lets retry wrappers re-issue the request without risking a double-apply (the SDK only auto-fills a fresh token per call, which defeats idempotency across caller-level retries).
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.
Types ¶
type RetryConfig ¶
type RetryConfig struct {
MaxAttempts int
InitialBackoff time.Duration
MaxBackoff time.Duration
BackoffMultiplier float64
}
RetryConfig controls retry behavior for AWS API calls.
type TTLCache ¶ added in v0.7.0
type TTLCache struct {
// contains filtered or unexported fields
}
TTLCache is a thread-safe in-memory cache with per-entry TTLs. Expired entries are deleted lazily on Get — a short-lived CLI process doesn't need a background janitor goroutine. It is the single cache implementation shared by the service packages (cluster and nodegroup previously kept near-identical copies).
func NewTTLCache ¶ added in v0.7.0
NewTTLCache creates a cache. defaultTTL is used by SetDefault; pass 0 if every Set call provides its own TTL.
func (*TTLCache) Clear ¶ added in v0.7.0
func (c *TTLCache) Clear()
Clear removes all items from the cache.
func (*TTLCache) Get ¶ added in v0.7.0
Get retrieves a value from the cache, lazily deleting expired entries.
func (*TTLCache) SetDefault ¶ added in v0.7.0
SetDefault stores a value with the cache's default TTL.