You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/core/breaker/nopbreaker.go

43 lines
765 B
Go

4 years ago
package breaker
const nopBreakerName = "nopBreaker"
4 years ago
type nopBreaker struct{}
4 years ago
func newNopBreaker() Breaker {
return nopBreaker{}
4 years ago
}
func (b nopBreaker) Name() string {
return nopBreakerName
4 years ago
}
func (b nopBreaker) Allow() (Promise, error) {
4 years ago
return nopPromise{}, nil
}
func (b nopBreaker) Do(req func() error) error {
4 years ago
return req()
}
func (b nopBreaker) DoWithAcceptable(req func() error, _ Acceptable) error {
4 years ago
return req()
}
func (b nopBreaker) DoWithFallback(req func() error, _ func(err error) error) error {
4 years ago
return req()
}
func (b nopBreaker) DoWithFallbackAcceptable(req func() error, _ func(err error) error,
_ Acceptable) error {
4 years ago
return req()
}
type nopPromise struct{}
func (p nopPromise) Accept() {
}
func (p nopPromise) Reject(_ string) {
4 years ago
}