traefik/middlewares/cbreaker.go

23 lines
626 B
Go
Raw Normal View History

2015-09-19 11:02:59 +00:00
package middlewares
2015-09-19 11:02:59 +00:00
import (
"net/http"
"github.com/containous/oxy/cbreaker"
2015-09-19 11:02:59 +00:00
)
// CircuitBreaker holds the oxy circuit breaker.
2015-09-19 11:02:59 +00:00
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...)
2015-09-19 11:02:59 +00:00
return &CircuitBreaker{circuitBreaker}
}
func (cb *CircuitBreaker) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
cb.circuitBreaker.ServeHTTP(rw, r)
}