Skip to content

Commit

Permalink
Add ResetCounters
Browse files Browse the repository at this point in the history
  • Loading branch information
rubyist committed Oct 13, 2014
1 parent 1911c2c commit 392136d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Changelog
All notable changes to this project will be documented in this file.

## 2.0.2 - 2014-10-13

### Added
- ResetCounters

### Deprecated
- Nothing

### Removed
- Nothing

### Fixed
- Nothing

## 2.0.1 - 2014-10-13

### Added
Expand Down
7 changes: 6 additions & 1 deletion circuitbreaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,15 @@ func (cb *Breaker) Trip() {
func (cb *Breaker) Reset() {
atomic.StoreInt32(&cb.broken, 0)
atomic.StoreInt32(&cb.tripped, 0)
cb.ResetCounters()
cb.sendEvent(BreakerReset)
}

// ResetCounters will reset only the failures, consecFailures, and success counters
func (cb *Breaker) ResetCounters() {
atomic.StoreInt64(&cb.failures, 0)
atomic.StoreInt64(&cb.consecFailures, 0)
atomic.StoreInt64(&cb.successes, 0)
cb.sendEvent(BreakerReset)
}

// Tripped returns true if the circuit breaker is tripped, false if it is reset.
Expand Down

0 comments on commit 392136d

Please sign in to comment.