Documentation ¶
Index ¶
- func DefaultIsRetryable(err error) bool
- func ExpBackoff(opts ...backoff.ExponentialBackOffOpts) func() time.Duration
- func ExpBackoffGenerator() func() time.Duration
- func FixedBackoff() time.Duration
- func FixedBackoffGenerator() func() time.Duration
- func NewRetryInterceptor(logger *slog.Logger, conf *RetryConfig) connect.UnaryInterceptorFunc
- type RetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultIsRetryable ¶
DefaultIsRetryable returns true if the error is caused by a network or connection error
func ExpBackoff ¶
ExpBackoff returns an exponential backoff duration based on cenkalti/backoff.
func ExpBackoffGenerator ¶
ExpBackoffGenerator returns an exponential backoff duration function
func FixedBackoff ¶
FixedBackoff returns a fixed backoff duration of 1 second.
func FixedBackoffGenerator ¶
FixedBackoffGenerator returns a fixed backoff duration function.
func NewRetryInterceptor ¶
func NewRetryInterceptor(logger *slog.Logger, conf *RetryConfig) connect.UnaryInterceptorFunc
NewRetryInterceptor returns a new retry interceptor.
Types ¶
type RetryConfig ¶
type RetryConfig struct { // A BackoffGenerator returns an instance of a backoff function for use with a single RPC call. // By default, it returns a fixed backoff of 1 second between attempts. // When the backoff function returns backoff.Stop (-1ns), the RPC call will not be retried. BackoffGenerator func() func() time.Duration // IsRetryable should return true if the error is retryable. // By default, it returns true for connect.CodeUnavailable and common network errors. IsRetryable func(error) bool // Set max attempts to <= 0 to retry indefinitely. MaxAttempts int }
RetryConfig contains the configuration for the retry interceptor
func DefaultRetryConfig ¶
func DefaultRetryConfig() *RetryConfig
DefaultRetryConfig returns a default retry configuration with a fixed backoff and retries on common network errors.
Click to show internal directories.
Click to hide internal directories.