Documentation ¶
Index ¶
- func AddJitter(duration time.Duration, jitter time.Duration) time.Duration
- func DefaultIfBlank(str string, defaultValue string) string
- func NewMultiError(errs ...error) error
- func ParseBool(str string, default_ bool) bool
- func RandHex() string
- func RetryNWithBackoff(backoff Backoff, n int, fn func() error) error
- func RetryNWithBackoffCtx(ctx context.Context, backoff Backoff, n int, fn func() error) error
- func RetryWithBackoff(backoff Backoff, fn func() error) error
- func RetryWithBackoffCtx(ctx context.Context, backoff Backoff, fn func() error) error
- func SlicesDeepEqual(slice1, slice2 interface{}) bool
- func StrSliceEqual(s1, s2 []string) bool
- func Strptr(s string) *string
- func Uint16SliceToStringSlice(slice []uint16) []*string
- func ZeroOrNil(obj interface{}) bool
- type AttributeError
- type Backoff
- type DefaultRetriable
- type DefaultRetriableError
- type MultiErr
- type Retriable
- type RetriableError
- type SimpleBackoff
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddJitter ¶
AddJitter adds an amount of jitter between 0 and the given jitter to the given duration
func RetryNWithBackoff ¶
RetryNWithBackoff takes a Backoff, a maximum number of tries 'n', and a function that returns an error. The function is called until either it does not return an error or the maximum tries have been reached. If the error returned is Retriable, the Retriability of it will be respected. If the number of tries is exhausted, the last error will be returned.
func RetryNWithBackoffCtx ¶
RetryNWithBackoffCtx takes a context, a Backoff, a maximum number of tries 'n', and a function that returns an error. The function is called until it does not return an error, the context is done, or the maximum tries have been reached. If the error returned is Retriable, the Retriability of it will be respected. If the number of tries is exhausted, the last error will be returned.
func RetryWithBackoff ¶
RetryWithBackoff takes a Backoff and a function to call that returns an error If the error is nil then the function will no longer be called If the error is Retriable then that will be used to determine if it should be retried
func RetryWithBackoffCtx ¶
RetryWithBackoffCtx takes a context, a Backoff, and a function to call that returns an error If the context is done, nil will be returned If the error is nil then the function will no longer be called If the error is Retriable then that will be used to determine if it should be retried
func SlicesDeepEqual ¶
func SlicesDeepEqual(slice1, slice2 interface{}) bool
SlicesDeepEqual checks if slice1 and slice2 are equal, disregarding order.
func Uint16SliceToStringSlice ¶
Uint16SliceToStringSlice converts a slice of type uint16 to a slice of type *string. It uses strconv.Itoa on each element
Types ¶
type AttributeError ¶
type AttributeError struct {
// contains filtered or unexported fields
}
func NewAttributeError ¶
func NewAttributeError(err string) AttributeError
func (AttributeError) Error ¶
func (e AttributeError) Error() string
type DefaultRetriable ¶
type DefaultRetriable struct {
// contains filtered or unexported fields
}
func (DefaultRetriable) Retry ¶
func (dr DefaultRetriable) Retry() bool
type DefaultRetriableError ¶
type DefaultRetriableError struct { Retriable // contains filtered or unexported fields }
type MultiErr ¶
type MultiErr struct {
// contains filtered or unexported fields
}
MultiErr Implements error
type RetriableError ¶
func NewRetriableError ¶
func NewRetriableError(retriable Retriable, err error) RetriableError
type SimpleBackoff ¶
type SimpleBackoff struct {
// contains filtered or unexported fields
}
func NewSimpleBackoff ¶
func NewSimpleBackoff(min, max time.Duration, jitterMultiple, multiple float64) *SimpleBackoff
NewSimpleBackoff creates a Backoff which ranges from min to max increasing by multiple each time. It also adds (and yes, the jitter is always added, never subtracted) a random amount of jitter up to jitterMultiple percent (that is, jitterMultiple = 0.0 is no jitter, 0.15 is 15% added jitter). The total time may exceed "max" when accounting for jitter, such that the absolute max is max + max * jiterMultiple
func (*SimpleBackoff) Duration ¶
func (sb *SimpleBackoff) Duration() time.Duration
func (*SimpleBackoff) Reset ¶
func (sb *SimpleBackoff) Reset()