25
25
Acceptable func (err error ) bool
26
26
27
27
Breaker interface {
28
- // Name returns the name of the netflixBreaker .
28
+ // Name returns the name of the Breaker .
29
29
Name () string
30
30
31
31
// Allow checks if the request is allowed.
@@ -34,34 +34,34 @@ type (
34
34
// If not allow, ErrServiceUnavailable will be returned.
35
35
Allow () (Promise , error )
36
36
37
- // Do runs the given request if the netflixBreaker accepts it.
38
- // Do returns an error instantly if the netflixBreaker rejects the request.
39
- // If a panic occurs in the request, the netflixBreaker handles it as an error
37
+ // Do runs the given request if the Breaker accepts it.
38
+ // Do returns an error instantly if the Breaker rejects the request.
39
+ // If a panic occurs in the request, the Breaker handles it as an error
40
40
// and causes the same panic again.
41
41
Do (req func () error ) error
42
42
43
- // DoWithAcceptable runs the given request if the netflixBreaker accepts it.
44
- // DoWithAcceptable returns an error instantly if the netflixBreaker rejects the request.
45
- // If a panic occurs in the request, the netflixBreaker handles it as an error
43
+ // DoWithAcceptable runs the given request if the Breaker accepts it.
44
+ // DoWithAcceptable returns an error instantly if the Breaker rejects the request.
45
+ // If a panic occurs in the request, the Breaker handles it as an error
46
46
// and causes the same panic again.
47
47
// acceptable checks if it's a successful call, even if the err is not nil.
48
48
DoWithAcceptable (req func () error , acceptable Acceptable ) error
49
49
50
- // DoWithFallback runs the given request if the netflixBreaker accepts it.
51
- // DoWithFallback runs the fallback if the netflixBreaker rejects the request.
52
- // If a panic occurs in the request, the netflixBreaker handles it as an error
50
+ // DoWithFallback runs the given request if the Breaker accepts it.
51
+ // DoWithFallback runs the fallback if the Breaker rejects the request.
52
+ // If a panic occurs in the request, the Breaker handles it as an error
53
53
// and causes the same panic again.
54
54
DoWithFallback (req func () error , fallback func (err error ) error ) error
55
55
56
- // DoWithFallbackAcceptable runs the given request if the netflixBreaker accepts it.
57
- // DoWithFallbackAcceptable runs the fallback if the netflixBreaker rejects the request.
58
- // If a panic occurs in the request, the netflixBreaker handles it as an error
56
+ // DoWithFallbackAcceptable runs the given request if the Breaker accepts it.
57
+ // DoWithFallbackAcceptable runs the fallback if the Breaker rejects the request.
58
+ // If a panic occurs in the request, the Breaker handles it as an error
59
59
// and causes the same panic again.
60
60
// acceptable checks if it's a successful call, even if the err is not nil.
61
61
DoWithFallbackAcceptable (req func () error , fallback func (err error ) error , acceptable Acceptable ) error
62
62
}
63
63
64
- BreakerOption func (breaker * circuitBreaker )
64
+ Option func (breaker * circuitBreaker )
65
65
66
66
Promise interface {
67
67
Accept ()
89
89
}
90
90
)
91
91
92
- func NewBreaker (opts ... BreakerOption ) Breaker {
92
+ func NewBreaker (opts ... Option ) Breaker {
93
93
var b circuitBreaker
94
94
for _ , opt := range opts {
95
95
opt (& b )
@@ -127,7 +127,7 @@ func (cb *circuitBreaker) Name() string {
127
127
return cb .name
128
128
}
129
129
130
- func WithName (name string ) BreakerOption {
130
+ func WithName (name string ) Option {
131
131
return func (b * circuitBreaker ) {
132
132
b .name = name
133
133
}
0 commit comments