Class: Resilient::CircuitBreaker::Metrics::Bucket
- Inherits:
-
Object
- Object
- Resilient::CircuitBreaker::Metrics::Bucket
- Defined in:
- lib/resilient/circuit_breaker/metrics/bucket.rb
Instance Attribute Summary collapse
-
#timestamp_end ⇒ Object
readonly
Returns the value of attribute timestamp_end.
-
#timestamp_start ⇒ Object
readonly
Returns the value of attribute timestamp_start.
Instance Method Summary collapse
- #include?(timestamp) ⇒ Boolean
-
#initialize(timestamp_start, timestamp_end) ⇒ Bucket
constructor
A new instance of Bucket.
- #prune_before(window_size) ⇒ Object
Constructor Details
#initialize(timestamp_start, timestamp_end) ⇒ Bucket
Returns a new instance of Bucket.
8 9 10 11 |
# File 'lib/resilient/circuit_breaker/metrics/bucket.rb', line 8 def initialize(, ) @timestamp_start = @timestamp_end = end |
Instance Attribute Details
#timestamp_end ⇒ Object (readonly)
Returns the value of attribute timestamp_end.
6 7 8 |
# File 'lib/resilient/circuit_breaker/metrics/bucket.rb', line 6 def @timestamp_end end |
#timestamp_start ⇒ Object (readonly)
Returns the value of attribute timestamp_start.
5 6 7 |
# File 'lib/resilient/circuit_breaker/metrics/bucket.rb', line 5 def @timestamp_start end |
Instance Method Details
#include?(timestamp) ⇒ Boolean
17 18 19 |
# File 'lib/resilient/circuit_breaker/metrics/bucket.rb', line 17 def include?() >= @timestamp_start && <= @timestamp_end end |
#prune_before(window_size) ⇒ Object
13 14 15 |
# File 'lib/resilient/circuit_breaker/metrics/bucket.rb', line 13 def prune_before(window_size) @timestamp_end - window_size.seconds end |