retry

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package retry provides a minimal, dependency-free bounded retry used by the core resource constructors to smooth transient connection failures at startup — e.g. a database or cache that is not yet reachable the moment the pod boots. It is intentionally tiny: fixed backoff, context-aware, no jitter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(ctx context.Context, attempts int, backoff time.Duration, operation func(context.Context) error) error

Do calls fn up to 1+attempts times: one initial attempt plus attempts retries. Between tries it waits backoff, aborting early if ctx is done. It returns nil on the first success, the last fn error joined with the context error when ctx is cancelled mid-wait, or the last fn error when the retry budget is exhausted.

attempts <= 0 or backoff <= 0 collapses to a single attempt (no retry), so Do is a transparent no-op wrapper when the caller did not opt in.

Types

This section is empty.

Jump to

Keyboard shortcuts

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