mirror of
https://github.com/containous/traefik.git
synced 2025-03-16 06:50:13 +03:00
23 lines
623 B
Go
23 lines
623 B
Go
package middlewares
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/mailgun/oxy/cbreaker"
|
|
)
|
|
|
|
// CircuitBreaker holds the oxy circuit breaker.
|
|
type CircuitBreaker struct {
|
|
circuitBreaker *cbreaker.CircuitBreaker
|
|
}
|
|
|
|
// NewCircuitBreaker returns a new CircuitBreaker.
|
|
func NewCircuitBreaker(next http.Handler, expression string, options ...cbreaker.CircuitBreakerOption) *CircuitBreaker {
|
|
circuitBreaker, _ := cbreaker.New(next, expression, options...)
|
|
return &CircuitBreaker{circuitBreaker}
|
|
}
|
|
|
|
func (cb *CircuitBreaker) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
|
cb.circuitBreaker.ServeHTTP(rw, r)
|
|
}
|