package retry

import "github.com/bitrise-io/go-utils/retry"

Index

Functions

func NewHTTPClient

func NewHTTPClient() *retryablehttp.Client

NewHTTPClient returns a retryable HTTP client

Types

type AbortableAction

type AbortableAction func(attempt uint) (error, bool)

AbortableAction ...

type Action

type Action func(attempt uint) error

Action ...

type HTTPLogAdaptor

type HTTPLogAdaptor struct{}

HTTPLogAdaptor adapts the retryablehttp.Logger interface to the go-utils logger.

func (*HTTPLogAdaptor) Printf

func (*HTTPLogAdaptor) Printf(fmtStr string, vars ...interface{})

Printf implements the retryablehttp.Logger interface

type Model

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

Model ...

func Times

func Times(retry uint) *Model

Times ...

func Wait

func Wait(waitTime time.Duration) *Model

Wait ...

func (*Model) Times

func (Model *Model) Times(retry uint) *Model

Times ...

func (Model) Try

func (Model Model) Try(action Action) error

Try continues executing the supplied action while this action parameter returns an error and the configured number of times has not been reached. Otherwise, it stops and returns the last received error.

func (Model) TryWithAbort

func (Model Model) TryWithAbort(action AbortableAction) error

TryWithAbort continues executing the supplied action while this action parameter returns an error, a false bool value and the configured number of times has not been reached. Returning a true value from the action aborts the retry loop.

Good for retrying actions which can return a mix of retryable and non-retryable failures.

func (*Model) Wait

func (Model *Model) Wait(waitTime time.Duration) *Model

Wait ...

Source Files

retry.go retryhttp.go

Version
v1.0.15 (latest)
Published
May 13, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
2 months ago

Tools for package owners.