strategy

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 3 Imported by: 93

Documentation

Overview

Package strategy provides a way to change the way that retry is performed.

Copyright © 2016 Trevor N. Suarez (Rican7)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Strategy

type Strategy func(attempt uint) bool

Strategy defines a function that Retry calls before every successive attempt to determine whether it should make the next attempt or not. Returning `true` allows for the next attempt to be made. Returning `false` halts the retrying process and returns the last error returned by the called Action.

The strategy will be passed an "attempt" number before each successive retry iteration, starting with a `0` value before the first attempt is actually made. This allows for a pre-action, such as a delay, etc.

func Backoff

func Backoff(algorithm backoff.Algorithm) Strategy

Backoff creates a Strategy that waits before each attempt, with a duration as defined by the given backoff.Algorithm.

func BackoffWithJitter

func BackoffWithJitter(algorithm backoff.Algorithm, transformation jitter.Transformation) Strategy

BackoffWithJitter creates a Strategy that waits before each attempt, with a duration as defined by the given backoff.Algorithm and jitter.Transformation.

func Delay

func Delay(duration time.Duration) Strategy

Delay creates a Strategy that waits the given duration before the first attempt is made.

func Limit

func Limit(attemptLimit uint) Strategy

Limit creates a Strategy that limits the number of attempts that Retry will make.

func Wait

func Wait(durations ...time.Duration) Strategy

Wait creates a Strategy that waits the given durations for each attempt after the first. If the number of attempts is greater than the number of durations provided, then the strategy uses the last duration provided.

Jump to

Keyboard shortcuts

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