Documentation
¶
Index ¶
- func RecoverWithContext(_ context.Context, operation string) error
- func WithGracefulDegrade[T any](operation string, config *GracefulDegradeConfig, defaultVal T, ...) T
- func WithRecover(operation string, fn func() error) (err error)
- func WithRetry(ctx context.Context, operation string, config *RetryConfig, fn func() error) error
- func WithRetryTyped[T any](ctx context.Context, operation string, config *RetryConfig, ...) (T, error)
- type CircuitBreakerConfig
- type GracefulDegradeConfig
- type RetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecoverWithContext ¶
RecoverWithContext handles panics and converts them to errors
func WithGracefulDegrade ¶
func WithGracefulDegrade[T any](operation string, config *GracefulDegradeConfig, defaultVal T, fn func() (T, error)) T
WithGracefulDegrade executes a function and returns a default value on error
func WithRecover ¶
WithRecover executes a function with panic recovery
func WithRetryTyped ¶
func WithRetryTyped[T any]( ctx context.Context, operation string, config *RetryConfig, fn func() (T, error), ) (T, error)
WithRetryTyped executes a function with retry logic and returns a typed result
Types ¶
type CircuitBreakerConfig ¶
type CircuitBreakerConfig struct { FailureThreshold uint // Number of failures before opening circuit SuccessThreshold uint // Number of successes before closing circuit Timeout time.Duration // Time to wait before attempting to close circuit }
CircuitBreakerConfig configures circuit breaker behavior
func DefaultCircuitBreakerConfig ¶
func DefaultCircuitBreakerConfig() *CircuitBreakerConfig
DefaultCircuitBreakerConfig returns sensible defaults
type GracefulDegradeConfig ¶
type GracefulDegradeConfig struct {
LogWarning bool
}
GracefulDegradeConfig configures graceful degradation behavior
type RetryConfig ¶
type RetryConfig struct { MaxAttempts uint InitialDelay time.Duration MaxDelay time.Duration Multiplier float64 RetryableErrors []string // Error codes that should trigger retry }
RetryConfig configures retry behavior
func DefaultRetryConfig ¶
func DefaultRetryConfig() *RetryConfig
DefaultRetryConfig returns sensible defaults
Click to show internal directories.
Click to hide internal directories.