Documentation ¶
Index ¶
Constants ¶
const DefaultJitterFraction = .05
Variables ¶
This section is empty.
Functions ¶
func DefaultRetryableErrorCheck ¶
DefaultRetryableErrorCheck returns true if err is an error that is retryable, i.e. implements RetryableError. This function is used to determine which errors to retry for the convenience methods on the rockset.RockClient.
Types ¶
type Exponential ¶
type Exponential struct { // MaxBackoff is the max time the exponential backoff can wait MaxBackoff time.Duration // WaitInterval is the initial interval wait between consecutive calls WaitInterval time.Duration // JitterFraction is the fraction of wait interval to use as jitter [0,1.0] JitterFraction float64 // RetryableErrorCheck is the function that determines if an error should be retried. // If nil, it uses the RetryableError(). RetryableErrorCheck func(error) bool }
Exponential is used to perform API call retries with exponential backoff.
func NewExponential ¶
func NewExponential() Exponential
NewExponential creates a new Retrier which uses exponential backoff.
func (Exponential) Retry ¶
func (r Exponential) Retry(ctx context.Context, retryFn Func) error
Retry retries retryFn until it returns an error. Uses exponential backoff. If the retryFn returns an error, it is wrapped in an Error, which implements RetryableError so the RetryableErrorCheck can determine if it should retry the operation.
func (Exponential) RetryWithCheck ¶
func (r Exponential) RetryWithCheck(ctx context.Context, checkFn CheckFn) error
RetryWithCheck will retry checkFn until it returns false or an error. If checkFn returns false, RetryWithCheck will return nil, otherwise it'll return the error.
type Func ¶
type Func func() (err error)
Func is the function Retrier will call as long as it returns an error which is retryable.
type Retrier ¶
type Retrier interface { // Retry will retry retryFn if it returns an error which is retryable Retry(ctx context.Context, retryFn Func) error // RetryWithCheck will retry checkFn until it returns false or an error RetryWithCheck(ctx context.Context, checkFunc CheckFn) error }
Retrier is the interface used by the RockClient convenience methods to retry an operation which returned an errors.Error which is Retryable().
type RetryableError ¶
RetryableError is an error which can be retried if Retryable() returns true.