resiliency

package
v0.0.0-...-88db892 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(parent context.Context, operation Operation, opts ...Option) error

Do executes the given operation and retries until it succeeds or exceeds timeout setting

func GetBackoffDurationInMs

func GetBackoffDurationInMs(backoffBaseInMs, backoffCapInMs, attempt float64) time.Duration

GetBackoffDurationInMs returns a backoff duration to avoid access contention Ref: https://www.awsarchitectureblog.com/2015/03/backoff.html

func Prepare

func Prepare(opts ...Option) func(parent context.Context, operation Operation) error

Prepare returns a wrapped retry operator with prepared options

Types

type IsIrrevocableErr

type IsIrrevocableErr func(error) (noRetry bool)

IsIrrevocableErr is a function that checks the supplied error and decides if the function should be retried or if we should immediately give up. For example, "data not found", "deadline exceeded" or "permission denied"

type Operation

type Operation func() error

Operation defines the function signature for actions needed retry

type Option

type Option func(*retryOptions)

Option is a function that configures retry operations

func WithBackoffBaseDelay

func WithBackoffBaseDelay(delayInMs int64) Option

WithBackoffBaseDelay configures the retryer to use the provided maximum delay when backing off after failed connection attempts.

func WithBackoffMaxDelay

func WithBackoffMaxDelay(delayInMs int64) Option

WithBackoffMaxDelay configures the retryer to use the provided maximum delay when backing off after failed connection attempts.

func WithCustomTags

func WithCustomTags(tag ...string) Option

WithCustomTags configures the retyer with custom statsd tags to be tracked

func WithInfiniteAttempts

func WithInfiniteAttempts() Option

WithInfiniteAttempts configures the retryer to hve no maximum retry limit, ie. continue retrying forever

func WithIsIrrevocableErrorHandler

func WithIsIrrevocableErrorHandler(fn func(error) (noRetry bool)) Option

WithIsIrrevocableErrorHandler configures the retryer to use the provided error handler

func WithMaxAttempts

func WithMaxAttempts(attempts int) Option

WithMaxAttempts configures the retryer to use the provided maximum attempts count when backing off after failed connection attempts.

func WithName

func WithName(name string) Option

WithName configures the retyer with custom name to be tracked

type Throttler

type Throttler interface {
	Throttle()
	ShutDown()
}

func InitializeThrottler

func InitializeThrottler(requestsPerInterval int, interval time.Duration) Throttler

Jump to

Keyboard shortcuts

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