retry

package
v2.16.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package retry provides a simple interface for retrying operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doer

type Doer interface {
	// Do performs an operation.
	//
	// It should return an error that can be checked for retriability.
	Do(ctx context.Context) error
}

Doer does something and returns an error.

type IntervalRetrier

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

IntervalRetrier retries a call with an interval. The call is defined in the Doer property.

func NewIntervalRetrier

func NewIntervalRetrier(doer Doer, interval time.Duration, retriable func(error) bool, optClock ...clock.WithTicker) *IntervalRetrier

NewIntervalRetrier returns a new IntervalRetrier. The optional clock is used for testing.

func (*IntervalRetrier) Do

func (r *IntervalRetrier) Do(ctx context.Context) error

Do retries performing a call until it succeeds, returns a permanent error or the context is cancelled.

Jump to

Keyboard shortcuts

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