mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-22 11:56:03 +03:00
fix logic flow and test
This commit is contained in:
parent
4ba68f1cbd
commit
baae348eb8
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,8 @@ func TestObjectBreaker(t *testing.T) {
|
||||
}
|
||||
|
||||
fmt.Println(string(body.([]byte)))
|
||||
|
||||
log.Print("\nresult:", body.([]byte))
|
||||
}
|
||||
|
||||
func TestFunctionalBreaker(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user