utils

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const Infinitely = -1

Infinitely, passed as maxTimes, makes a runner retry until success or, for RunContext, until the context ends.

Variables

View Source
var ErrMaxRetriesExceeded = errors.New("maximum number of retries exceeded")

ErrMaxRetriesExceeded is returned, possibly joined with the last attempt's error, when a runner exhausts its attempts without success.

Functions

func GenerateBytesUUID

func GenerateBytesUUID() []byte

GenerateBytesUUID creates a new random UUID and returns it as []byte

func GenerateUUID

func GenerateUUID() string

GenerateUUID creates a new random UUID and returns it as a string

func NewBackoffRetryRunner added in v0.26.0

func NewBackoffRetryRunner(maxTimes int, initial, maxDelay time.Duration) *retryRunner

NewBackoffRetryRunner returns a runner with exponential backoff and full jitter: the n-th delay is drawn uniformly from [0, min(initial*2^n, maxDelay)). The randomness on every attempt keeps many nodes from retrying a recovering service in lockstep, and maxDelay bounds the wait. If maxDelay < initial, maxDelay is raised to initial. A non-positive initial retries without waiting.

func NewProbabilisticRetryRunner

func NewProbabilisticRetryRunner(maxTimes int, interval int64, expBackoff bool) *retryRunner

NewProbabilisticRetryRunner returns a runner whose first delay is a random value in [1, interval] milliseconds. Later delays follow NewRetryRunner.

func NewRetryRunner

func NewRetryRunner(maxTimes int, delay time.Duration, expBackoff bool) *retryRunner

NewRetryRunner returns a runner that waits delay between attempts, doubling it after each attempt if expBackoff is set.

func NewTypedRetryRunner

func NewTypedRetryRunner[V any](maxTimes int, delay time.Duration, expBackoff bool) *typedRetryRunner[V]

NewTypedRetryRunner returns a runner like NewRetryRunner whose Run also returns the value produced by the successful attempt.

Types

This section is empty.

Directories

Path Synopsis
Package buildinfo reports what the Go toolchain embedded in the running binary about the FSC module, the application module and the VCS revision.
Package buildinfo reports what the Go toolchain embedded in the running binary about the FSC module, the application module and the VCS revision.
Package compose builds and splits composite keys from object types and attributes.
Package compose builds and splits composite keys from object types and attributes.
Package configtest checks the reference configuration in docs/configuration.md against the code that reads it.
Package configtest checks the reference configuration in docs/configuration.md against the code that reads it.
Package errors provides helpers for creating, annotating, wrapping, and joining errors, and for inspecting their causes and types.
Package errors provides helpers for creating, annotating, wrapping, and joining errors, and for inspecting their causes and types.
Package proto provides Protocol Buffer marshaling, unmarshaling, equality, and cloning helpers.
Package proto provides Protocol Buffer marshaling, unmarshaling, equality, and cloning helpers.

Jump to

Keyboard shortcuts

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