sdk

package
v1.0.25 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NeverAbort added in v1.0.15

func NeverAbort() error

func RetryForError

func RetryForError(api func() error, retries int, abort func() error, sleep time.Duration, logger log.Logger) (err error)

RetryForError loop max `retries` count to call api(). returns the error if api() returns a non Retryable error. returns the error if abort() returns error. call SleepForRetry(sleep, after, abort), if api() returns a Retryable error.

func SleepForRetry added in v1.0.15

func SleepForRetry(sleep, after time.Duration, abort func() error) (err error)

SleepForRetry loop to sleep(`sleep`) until 'after' duration elapsed. call 'abort()' every 'sleep' interval, if abort() returns error, returns it. if 'sleep' <= 0, 'sleep' = time.Second. if 'sleep' > 'after', 'sleep' = 'after'.

Types

type NetError added in v1.0.11

type NetError struct {
	Err        error
	RetryAfter time.Duration
}

func NewNetError added in v1.0.11

func NewNetError(err error, retryAfter ...time.Duration) *NetError

func (*NetError) Error added in v1.0.11

func (ne *NetError) Error() string

func (*NetError) GetRetryAfter added in v1.0.15

func (ne *NetError) GetRetryAfter() time.Duration

func (*NetError) Unwrap added in v1.0.11

func (ne *NetError) Unwrap() error

type Retryable added in v1.0.16

type Retryable interface {
	GetRetryAfter() time.Duration
}

Directories

Path Synopsis
fdk

Jump to

Keyboard shortcuts

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