diff --git a/middleware/circuitbreaker/circuitbreaker.go b/middleware/circuitbreaker/circuitbreaker.go index 31433ee71..76f261fd2 100644 --- a/middleware/circuitbreaker/circuitbreaker.go +++ b/middleware/circuitbreaker/circuitbreaker.go @@ -26,6 +26,15 @@ func WithGroup(g *group.Group) Option { } } +// WithCircuitBreaker with circuit breaker genFunc. +func WithCircuitBreaker(genBreakerFunc func() circuitbreaker.CircuitBreaker) Option { + return func(o *options) { + o.group = group.NewGroup(func() interface{} { + return genBreakerFunc() + }) + } +} + type options struct { group *group.Group }