KB
Tighten retry backoff jitter; cap at 30s
a8f3c0e
· 2 days ago
README.md
utils
A small, opinionated bundle of Go helpers used across kb/* services —
retry/backoff, slug, env loading, structured errors. Zero non-stdlib runtime
dependencies; everything else is dev-only.
Install
# Go module
go get code.kbenestad.net/kb/utils@v2.4.0
# Or via kbpkg, our internal package manager
kbpkg install kb/utils
Usage
package main
import (
"context"
"code.kbenestad.net/kb/utils/retry"
)
func main() {
ctx := context.Background()
_ = retry.Do(ctx, retry.Default, func() error {
// network call here
return nil
})
}
What's inside
retry— context-aware exponential backoff with full jitter (cap 30s).slug— Unicode-correct slugification; handles combining marks.envx— typed env loading with defaults and required-key checks.errs— structured error wrapping that survives JSON round-trips.iox— small io helpers (limited readers, atomic file writes).
Stability
Public API follows semver. Anything under internal/ is fair game and
will change without notice.