Class: OpsDeploy::Waiter
- Inherits:
-
Thread
- Object
- Thread
- OpsDeploy::Waiter
- Defined in:
- lib/ops_deploy/waiter.rb
Overview
A class defining a generic ‘waiter’ thread that waits for tasks to finish
Direct Known Subclasses
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#data ⇒ Object
Returns the value of attribute data.
-
#end_when ⇒ Object
Returns the value of attribute end_when.
Instance Method Summary collapse
-
#initialize(&task) ⇒ Waiter
constructor
A new instance of Waiter.
Constructor Details
#initialize(&task) ⇒ Waiter
Returns a new instance of Waiter.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ops_deploy/waiter.rb', line 5 def initialize(&task) @task = task super() do error = nil begin loop do @data = @task.call break if @end_when.call(@data) sleep 5 end rescue StandardError => e error = e end @callback.call(@data, error) if @callback @data end end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
3 4 5 |
# File 'lib/ops_deploy/waiter.rb', line 3 def callback @callback end |
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/ops_deploy/waiter.rb', line 3 def data @data end |
#end_when ⇒ Object
Returns the value of attribute end_when.
3 4 5 |
# File 'lib/ops_deploy/waiter.rb', line 3 def end_when @end_when end |