breaker

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 4 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 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 ...Logger) *Breaker

func New added in v0.1.0

func New(log 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.

type Logger

type Logger interface {
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
}

Jump to

Keyboard shortcuts

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