retry

package
v0.0.0-...-a423d60 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Attempts uint          `envconfig:"APP_HTTP_RETRY_ATTEMPTS"`
	Delay    time.Duration `envconfig:"APP_HTTP_RETRY_DELAY"`
}

Config configuration for the HTTPExecutor

type ExecutableHTTPFunc

type ExecutableHTTPFunc func() (*http.Response, error)

ExecutableHTTPFunc defines a generic HTTP function to be executed

type HTTPExecutor

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

HTTPExecutor is capable of executing HTTP requests with a leveraged retry mechanism for more resilience

func NewHTTPExecutor

func NewHTTPExecutor(config *Config) *HTTPExecutor

NewHTTPExecutor constructs an HTTPExecutor based on the provided Config

func (*HTTPExecutor) Execute

func (he *HTTPExecutor) Execute(doRequest ExecutableHTTPFunc) (*http.Response, error)

Execute wraps the provided ExecutableHTTPFunc with a retry mechanism and executes it

func (*HTTPExecutor) WithAcceptableStatusCodes

func (he *HTTPExecutor) WithAcceptableStatusCodes(statusCodes []int)

WithAcceptableStatusCodes allows overriding the default acceptableStatusCodes values

Jump to

Keyboard shortcuts

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