Class: WSDirector::Result
- Inherits:
-
Object
- Object
- WSDirector::Result
- Defined in:
- lib/wsdirector/result.rb
Overview
Handle results from all clients from the group
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
Instance Method Summary collapse
-
#failed(error_message) ⇒ Object
Called when client failed.
- #failures_count ⇒ Object
-
#initialize(group) ⇒ Result
constructor
A new instance of Result.
-
#succeed ⇒ Object
Called when client successfully finished it’s work.
- #success? ⇒ Boolean
- #total_count ⇒ Object
Constructor Details
#initialize(group) ⇒ Result
Returns a new instance of Result.
8 9 10 11 12 13 14 |
# File 'lib/wsdirector/result.rb', line 8 def initialize(group) @group = group @errors = Concurrent::Array.new @all = Concurrent::AtomicFixnum.new(0) @failures = Concurrent::AtomicFixnum.new(0) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/wsdirector/result.rb', line 6 def errors @errors end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
6 7 8 |
# File 'lib/wsdirector/result.rb', line 6 def group @group end |
Instance Method Details
#failed(error_message) ⇒ Object
Called when client failed
22 23 24 25 26 |
# File 'lib/wsdirector/result.rb', line 22 def failed() errors << all.increment failures.increment end |
#failures_count ⇒ Object
36 37 38 |
# File 'lib/wsdirector/result.rb', line 36 def failures_count failures.value end |
#succeed ⇒ Object
Called when client successfully finished it’s work
17 18 19 |
# File 'lib/wsdirector/result.rb', line 17 def succeed all.increment end |
#success? ⇒ Boolean
28 29 30 |
# File 'lib/wsdirector/result.rb', line 28 def success? failures.value.zero? end |
#total_count ⇒ Object
32 33 34 |
# File 'lib/wsdirector/result.rb', line 32 def total_count all.value end |