diff --git a/resiliency/06_circuit_breaker/circuit_breaker_adv.go b/resiliency/06_circuit_breaker/circuit_breaker_adv.go index 437386c..4b8f11f 100644 --- a/resiliency/06_circuit_breaker/circuit_breaker_adv.go +++ b/resiliency/06_circuit_breaker/circuit_breaker_adv.go @@ -96,15 +96,15 @@ func (rb *RequestBreaker) beforeRequest() error { rb.options.Expiry = time.Now().Add(rb.options.Timeout) return nil } + return ErrTooManyRequests case StateClosed: if rb.options.Expiry.Before(time.Now()) { rb.cnter.Reset() rb.options.Expiry = time.Now().Add(rb.options.Interval) } - } - return ErrTooManyRequests + return nil } diff --git a/resiliency/06_circuit_breaker/circuit_breaker_test.go b/resiliency/06_circuit_breaker/circuit_breaker_test.go index d35468e..38c81fe 100644 --- a/resiliency/06_circuit_breaker/circuit_breaker_test.go +++ b/resiliency/06_circuit_breaker/circuit_breaker_test.go @@ -71,6 +71,8 @@ func TestObjectBreaker(t *testing.T) { } fmt.Println(string(body.([]byte))) + + log.Print("\nresult:", body.([]byte)) } func TestFunctionalBreaker(t *testing.T) {