1
0
mirror of https://github.com/containous/traefik.git synced 2024-12-25 23:21:40 +03:00
traefik/middlewares/cbreaker.go

26 lines
677 B
Go
Raw Normal View History

2015-09-19 14:02:59 +03:00
package middlewares
2015-09-19 14:02:59 +03:00
import (
"net/http"
"github.com/vulcand/oxy/cbreaker"
2015-09-19 14:02:59 +03:00
)
// CircuitBreaker holds the oxy circuit breaker.
2015-09-19 14:02:59 +03:00
type CircuitBreaker struct {
circuitBreaker *cbreaker.CircuitBreaker
}
// NewCircuitBreaker returns a new CircuitBreaker.
func NewCircuitBreaker(next http.Handler, expression string, options ...cbreaker.CircuitBreakerOption) (*CircuitBreaker, error) {
circuitBreaker, err := cbreaker.New(next, expression, options...)
if err != nil {
return nil, err
}
return &CircuitBreaker{circuitBreaker}, nil
2015-09-19 14:02:59 +03:00
}
func (cb *CircuitBreaker) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
cb.circuitBreaker.ServeHTTP(rw, r)
}