Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
func Do(ctx context.Context, config Config, fn RetryableFunc) error
Do executes a function with retry logic
func DoWithResult ¶
func DoWithResult[T any](ctx context.Context, config Config, fn RetryableFuncWithResult[T]) (T, error)
DoWithResult executes a function with retry logic and returns a result
func IsRetryableError ¶
IsRetryableError checks if an error is retryable
Types ¶
type Config ¶
type Config struct {
MaxAttempts int // Maximum number of retry attempts
BaseDelay time.Duration // Base delay between retries
MaxDelay time.Duration // Maximum delay between retries
Multiplier float64 // Multiplier for exponential backoff
Jitter bool // Add random jitter to delays
RetryOn []types.ErrorType // Error types to retry on
}
Config holds retry configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a sensible default retry configuration
func ServiceNowRetryConfig ¶
func ServiceNowRetryConfig() Config
ServiceNowRetryConfig returns retry configuration optimized for ServiceNow API
type RetryableError ¶
type RetryableError struct {
Err error
}
RetryableError wraps an error to indicate it should be retried
func NewRetryableError ¶
func NewRetryableError(err error) *RetryableError
NewRetryableError creates a new retryable error
func (*RetryableError) Error ¶
func (r *RetryableError) Error() string
func (*RetryableError) Unwrap ¶
func (r *RetryableError) Unwrap() error
type RetryableFunc ¶
type RetryableFunc func() error
RetryableFunc is a function that can be retried
type RetryableFuncWithResult ¶
RetryableFuncWithResult is a function that returns a result and can be retried
Click to show internal directories.
Click to hide internal directories.