Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCircuitBreakerOpen is returned when the circuit breaker is in the open state ErrCircuitBreakerOpen = errors.New("circuit-breaker", "circuit-breaker", "circuit breaker is open", nil) ErrServiceUnavailable = errors.New("service", "availability", "service unavailable", nil) // ErrContextCanceled is returned when the context is canceled ErrContextCanceled = errors.New("context", "canceled", "context canceled", nil) // ErrContextDeadlineExceeded is returned when the context deadline is exceeded ErrContextDeadlineExceeded = errors.New("context", "deadline-exceeded", "context deadline exceeded", nil) )
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker implements the circuit breaker pattern
func NewCircuitBreaker ¶
func NewCircuitBreaker(failureThreshold int, cooldownPeriod time.Duration) *CircuitBreaker
NewCircuitBreaker creates a new circuit breaker
func (*CircuitBreaker) Execute ¶
func (cb *CircuitBreaker) Execute(ctx context.Context, operation func() error) (err error)
Execute executes an operation with circuit breaker protection
func (*CircuitBreaker) ExecuteWithName ¶
func (cb *CircuitBreaker) ExecuteWithName(ctx context.Context, operationName string, operation func() error) (err error)
ExecuteWithName executes an operation with circuit breaker protection and a specific operation name
type RecoveryHandler ¶
type RecoveryHandler struct {
// contains filtered or unexported fields
}
RecoveryHandler handles panic recovery and error rate limiting
func NewRecoveryHandler ¶
func NewRecoveryHandler(logger *logging.ContextLogger, errorsPerSecond int) *RecoveryHandler
NewRecoveryHandler creates a new recovery handler with error rate limiting
func (*RecoveryHandler) WithRecovery ¶
func (h *RecoveryHandler) WithRecovery(ctx context.Context, operation string, fn func() error) (err error)
WithRecovery wraps an operation with panic recovery and error rate limiting
Click to show internal directories.
Click to hide internal directories.