Documentation
¶
Overview ¶
Package retry provides a generic async function executor with retries for robustness against network failures. Functions are linked to a deadline, executed asynchronously and network or context errors retried with backoff until the deadline has elapsed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Retryer ¶
type Retryer[T any] struct { // contains filtered or unexported fields }
Retryer provides execution of functions asynchronously with retry adding robustness to network errors. The generic type T abstracts the deadline argument.
func NewForT ¶
func NewForT[T any]( _ *testing.T, ctxTimeoutFunc func(context.Context, T) (context.Context, context.CancelFunc), backoffProvider func() func() <-chan time.Time, ) (*Retryer[T], error)
NewForT returns a new Retryer instance for testing supporting a custom clock.
func (*Retryer[T]) DoAsync ¶
func (r *Retryer[T]) DoAsync(parent context.Context, t T, topic, name string, fn func(context.Context) error)
DoAsync will execute the function including retries on network or context errors. It is intended to be used asynchronously:
go retryer.DoAsync(ctx, duty, "foo", fn)
Click to show internal directories.
Click to hide internal directories.