retry

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package retry ... Copyright 2019 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(fn RetriableFunc, opts ...Option) error

Do retries the execution of the given function until it finishes successfully, it returns a nil error, or a timeout is reached.

If the function returns a non-nil error, a delay will be applied before executing the onRetry function on the error and retrying the function.

Types

type OnRetryFunc

type OnRetryFunc func(err error)

OnRetryFunc is executed after a RetrieableFunc fails and receives the returned error as argument.

type Option

type Option func(*config)

Option to be applied to the retry config.

func Delay

func Delay(delay time.Duration) Option

Delay is the time to wait after a failed execution before retrying.

func OnRetry

func OnRetry(fn OnRetryFunc) Option

OnRetry sets a new function to be applied to the error returned by the function execution.

func Timeout

func Timeout(timeout time.Duration) Option

Timeout sets the time duration to wait before aborting the retries if there are not successful executions of the function.

type RetriableFunc

type RetriableFunc func() error

RetriableFunc is a function to be retried in order to get a successful execution. In general this are functions which success depend on external conditions that can eventually be met.

Jump to

Keyboard shortcuts

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