Class: Async::Container::Statistics
- Inherits:
-
Object
- Object
- Async::Container::Statistics
- Defined in:
- lib/async/container/statistics.rb
Overview
Tracks various statistics relating to child instances in a container.
Instance Attribute Summary collapse
-
#failures ⇒ Object
readonly
How many child instances have failed.
-
#restarts ⇒ Object
readonly
How many child instances have been restarted.
-
#spawns ⇒ Object
readonly
How many child instances have been spawned.
Instance Method Summary collapse
-
#<<(other) ⇒ Object
Append another statistics instance into this one.
-
#failed? ⇒ Boolean
Whether there have been any failures.
-
#failure! ⇒ Object
Increment the number of failures by 1.
-
#initialize ⇒ Statistics
constructor
A new instance of Statistics.
-
#restart! ⇒ Object
Increment the number of restarts by 1.
-
#spawn! ⇒ Object
Increment the number of spawns by 1.
Constructor Details
#initialize ⇒ Statistics
Returns a new instance of Statistics.
29 30 31 32 33 |
# File 'lib/async/container/statistics.rb', line 29 def initialize @spawns = 0 @restarts = 0 @failures = 0 end |
Instance Attribute Details
#failures ⇒ Object (readonly)
How many child instances have failed.
45 46 47 |
# File 'lib/async/container/statistics.rb', line 45 def failures @failures end |
#restarts ⇒ Object (readonly)
How many child instances have been restarted.
41 42 43 |
# File 'lib/async/container/statistics.rb', line 41 def restarts @restarts end |
#spawns ⇒ Object (readonly)
How many child instances have been spawned.
37 38 39 |
# File 'lib/async/container/statistics.rb', line 37 def spawns @spawns end |
Instance Method Details
#<<(other) ⇒ Object
Append another statistics instance into this one.
70 71 72 73 74 |
# File 'lib/async/container/statistics.rb', line 70 def << other @spawns += other.spawns @restarts += other.restarts @failures += other.failures end |
#failed? ⇒ Boolean
Whether there have been any failures.
64 65 66 |
# File 'lib/async/container/statistics.rb', line 64 def failed? @failures > 0 end |
#failure! ⇒ Object
Increment the number of failures by 1.
58 59 60 |
# File 'lib/async/container/statistics.rb', line 58 def failure! @failures += 1 end |
#restart! ⇒ Object
Increment the number of restarts by 1.
53 54 55 |
# File 'lib/async/container/statistics.rb', line 53 def restart! @restarts += 1 end |
#spawn! ⇒ Object
Increment the number of spawns by 1.
48 49 50 |
# File 'lib/async/container/statistics.rb', line 48 def spawn! @spawns += 1 end |