Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backoff ¶
type Backoff struct {
// contains filtered or unexported fields
}
Backoff implements exponential backoff with randomized wait times
func New ¶
func New(ctx context.Context, cfg Config) *Backoff
New creates a Backoff object. Pass a Context that can also terminate the operation.
func (*Backoff) Err ¶
func (b *Backoff) Err() error
Err returns the reason for terminating the backoff, or nil if it didn't terminate
func (*Backoff) NumRetries ¶
func (b *Backoff) NumRetries() int
NumRetries returns the number of retries so far
type Config ¶
type Config struct {
MinBackoff time.Duration `yaml:"min_period"` // start backoff at this level
MaxBackoff time.Duration `yaml:"max_period"` // increase exponentially to this level
MaxRetries int `yaml:"max_retries"` // give up after this many; zero means infinite retries
}
Config configures a Backoff
func (*Config) RegisterFlagsWithPrefix ¶
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)
RegisterFlagsWithPrefix for Config.
Click to show internal directories.
Click to hide internal directories.