timeutil

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Periodically

func Periodically(ctx context.Context, interval time.Duration, f func() error) error

Invoke f immediately, and once for every interval after that until f returns an error or context is canceled. Returns the first error from f, or ctx.Err() if the context is canceled.

func RetryDuration

func RetryDuration(numRetries int, minDuration time.Duration, maxDuration time.Duration) time.Duration

Return a duration in the range [minDuration, maxDuration) that is suitable for waiting before retrying an operation. numRetries is the number of prior retries. The duration gets exponentially longer as numRetries gets larger, and contains random jitter.

func SleepContext

func SleepContext(ctx context.Context, duration time.Duration) error

Sleep for duration, or until context is canceled. Returns ctx.Err() if and only if context is canceled before the duration elapses.

Types

This section is empty.

Jump to

Keyboard shortcuts

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