retry

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestFastRetries

func TestFastRetries(_ testing.TB)

TestFastRetries reduces the initial retry delay to 1 millisecond

Types

type Backend

type Backend struct {
	restic.Backend
	MaxTries int
	Report   func(string, error, time.Duration)
	Success  func(string, int)
}

Backend retries operations on the backend in case of an error with a backoff.

func New

func New(be restic.Backend, maxTries int, report func(string, error, time.Duration), success func(string, int)) *Backend

New wraps be with a backend that retries operations after a backoff. report is called with a description and the error, if one occurred. success is called with the number of retries before a successful operation (it is not called if it succeeded on the first try)

func (*Backend) List

func (be *Backend) List(ctx context.Context, t restic.FileType, fn func(restic.FileInfo) error) error

List runs fn for each file in the backend which has the type t. When an error is returned by the underlying backend, the request is retried. When fn returns an error, the operation is aborted and the error is returned to the caller.

func (*Backend) Load

func (be *Backend) Load(ctx context.Context, h restic.Handle, length int, offset int64, consumer func(rd io.Reader) error) (err error)

Load returns a reader that yields the contents of the file at h at the given offset. If length is larger than zero, only a portion of the file is returned. rd must be closed after use. If an error is returned, the ReadCloser must be nil.

func (*Backend) Remove

func (be *Backend) Remove(ctx context.Context, h restic.Handle) (err error)

Remove removes a File with type t and name.

func (*Backend) Save

Save stores the data in the backend under the given handle.

func (*Backend) Stat

func (be *Backend) Stat(ctx context.Context, h restic.Handle) (fi restic.FileInfo, err error)

Stat returns information about the File identified by h.

func (*Backend) Unwrap

func (be *Backend) Unwrap() restic.Backend

Jump to

Keyboard shortcuts

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