breaker

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 4

README

breaker

..

Example

..

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFatal         = errors.New("breaker: fatal error")
	ErrHitMaxRetries = errors.New("breaker: hit max retries")
)

Functions

func Do added in v0.1.0

func Do(ctx context.Context, fn func() error, log *slog.Logger, backoff time.Duration, factor float64, maxTries int) error

Types

type Breaker added in v0.1.0

type Breaker struct {
	// contains filtered or unexported fields
}

func Default added in v0.1.0

func Default(optLog ...*slog.Logger) *Breaker

func New added in v0.1.0

func New(log *slog.Logger, backoff time.Duration, factor float64, maxTries int) *Breaker

func (*Breaker) Do added in v0.1.0

func (b *Breaker) Do(ctx context.Context, fn func() error) error

Do is an exponential-backoff-retry caller which will wait `backoff*factor**retry` up to `maxTries` `maxTries = 1` means retry only once when an error occurs.

Jump to

Keyboard shortcuts

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