forked from zeromicro/go-zero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nopbreaker.go
42 lines (30 loc) · 813 Bytes
/
nopbreaker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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 Acceptable) error {
return req()
}
func (b noOpBreaker) DoWithFallback(req func() error, fallback func(err error) error) error {
return req()
}
func (b noOpBreaker) DoWithFallbackAcceptable(req func() error, fallback func(err error) error,
acceptable Acceptable) error {
return req()
}
type nopPromise struct{}
func (p nopPromise) Accept() {
}
func (p nopPromise) Reject(reason string) {
}