2020-07-26 17:09:05 +08:00
|
|
|
package breaker
|
|
|
|
|
|
|
|
const noOpBreakerName = "nopBreaker"
|
|
|
|
|
|
|
|
type noOpBreaker struct{}
|
|
|
|
|
|
|
|
func newNoOpBreaker() Breaker {
|
|
|
|
return noOpBreaker{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b noOpBreaker) Name() string {
|
|
|
|
return noOpBreakerName
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b noOpBreaker) Allow() (Promise, error) {
|
|
|
|
return nopPromise{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b noOpBreaker) Do(req func() error) error {
|
|
|
|
return req()
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:41:50 +08:00
|
|
|
func (b noOpBreaker) DoWithAcceptable(req func() error, _ Acceptable) error {
|
2020-07-26 17:09:05 +08:00
|
|
|
return req()
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:41:50 +08:00
|
|
|
func (b noOpBreaker) DoWithFallback(req func() error, _ func(err error) error) error {
|
2020-07-26 17:09:05 +08:00
|
|
|
return req()
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:41:50 +08:00
|
|
|
func (b noOpBreaker) DoWithFallbackAcceptable(req func() error, _ func(err error) error,
|
|
|
|
_ Acceptable) error {
|
2020-07-26 17:09:05 +08:00
|
|
|
return req()
|
|
|
|
}
|
|
|
|
|
|
|
|
type nopPromise struct{}
|
|
|
|
|
|
|
|
func (p nopPromise) Accept() {
|
|
|
|
}
|
|
|
|
|
2022-12-11 00:41:50 +08:00
|
|
|
func (p nopPromise) Reject(_ string) {
|
2020-07-26 17:09:05 +08:00
|
|
|
}
|