Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCircuitOpen = errors.New("circuit breaker is open") ErrCircuitExhausted = errors.New("circuit breaker is exhausted") )
Functions ¶
This section is empty.
Types ¶
type CircuitBreakerMiddleware ¶
type CircuitBreakerMiddleware struct {
// contains filtered or unexported fields
}
CircuitBreakerMiddleware implements the circuit breaker pattern to prevent cascading failures.
func New ¶
func New(maxRequests uint32, interval, timeout time.Duration) *CircuitBreakerMiddleware
New creates a new CircuitBreakerMiddleware instance.
func (*CircuitBreakerMiddleware) Process ¶
func (m *CircuitBreakerMiddleware) Process(ctx context.Context, httpClient *http.Client, req *http.Request, next middleware.NextFunc) (*http.Response, error)
Process applies the circuit breaker before passing the request to the next middleware.
func (*CircuitBreakerMiddleware) SetLogger ¶
func (m *CircuitBreakerMiddleware) SetLogger(l logger.Logger)
SetLogger sets the logger for the middleware.
Click to show internal directories.
Click to hide internal directories.