From 8732b763869697f6d76a0b216ebe3e1b069adb55 Mon Sep 17 00:00:00 2001 From: Ccheers <1048315650@qq.com> Date: Tue, 29 Nov 2022 11:23:02 +0800 Subject: [PATCH] fix(circuitbreaker): add WithCircuitBreaker to fix WithGroup is useless (#2535) --- middleware/circuitbreaker/circuitbreaker.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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 }