retry

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package retry provides a generic async slot function executor with retries for robustness against network failures. Functions are linked to a slot, executed asynchronously and network or context errors retried with backoff until duties related to a slot have elapsed (5 slots later).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Retryer

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

Retryer provides execution of functions asynchronously with retry adding robustness to network errors.

func New

func New(ctx context.Context, eth2Svc eth2client.Service) (*Retryer, error)

New returns a new Retryer instance.

func NewForT

func NewForT(
	_ *testing.T,
	ctxTimeoutFunc func(ctx context.Context, slot int64) (context.Context, context.CancelFunc),
	backoffProvider func() func() <-chan time.Time,
) (*Retryer, error)

NewForT returns a new Retryer instance for testing supporting a custom clock.

func (*Retryer) DoAsync

func (r *Retryer) DoAsync(parent context.Context, slot int64, 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.Slot, "foo", fn)

func (*Retryer) Shutdown

func (r *Retryer) Shutdown(ctx context.Context)

Shutdown triggers graceful shutdown and waits for all active function to complete or timeout.

Jump to

Keyboard shortcuts

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