mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
fdc57d07d7
* fix: #2672 * chore: fix more cases * chore: update deps * chore: update deps * chore: refactor * chore: refactor * chore: refactor
43 lines
776 B
Go
43 lines
776 B
Go
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()
|
|
}
|
|
|
|
func (b noOpBreaker) DoWithAcceptable(req func() error, _ Acceptable) error {
|
|
return req()
|
|
}
|
|
|
|
func (b noOpBreaker) DoWithFallback(req func() error, _ func(err error) error) error {
|
|
return req()
|
|
}
|
|
|
|
func (b noOpBreaker) DoWithFallbackAcceptable(req func() error, _ func(err error) error,
|
|
_ Acceptable) error {
|
|
return req()
|
|
}
|
|
|
|
type nopPromise struct{}
|
|
|
|
func (p nopPromise) Accept() {
|
|
}
|
|
|
|
func (p nopPromise) Reject(_ string) {
|
|
}
|