Codebase list golang-gopkg-eapache-go-resiliency.v1 / 4d1b054
Give the function parameters slightly more useful names Evan Huus 9 years ago
1 changed file(s) with 4 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
4545 // Run will either return ErrBreakerOpen immediately if the circuit-breaker is
4646 // already open, or it will run the given function and pass along its return
4747 // value. It is safe to call Run concurrently on the same Breaker.
48 func (b *Breaker) Run(x func() error) error {
48 func (b *Breaker) Run(work func() error) error {
4949 b.lock.RLock()
5050 state := b.state
5151 b.lock.RUnlock()
6060 defer func() {
6161 panicValue = recover()
6262 }()
63 return x()
63 return work()
6464 }()
6565
6666 if result == nil && panicValue == nil && state == closed {
8585 // If the function is run, Go will return nil immediately, and will *not* return
8686 // the return value of the function. It is safe to call Go concurrently on the
8787 // same Breaker.
88 func (b *Breaker) Go(x func() error) error {
88 func (b *Breaker) Go(work func() error) error {
8989 b.lock.RLock()
9090 state := b.state
9191 b.lock.RUnlock()
101101 defer func() {
102102 panicValue = recover()
103103 }()
104 return x()
104 return work()
105105 }()
106106
107107 if result == nil && panicValue == nil && state == closed {