Class: Hippo::DeploymentMonitor
- Inherits:
-
Object
- Object
- Hippo::DeploymentMonitor
- Defined in:
- lib/hippo/deployment_monitor.rb
Defined Under Namespace
Classes: Poll
Instance Method Summary collapse
-
#initialize(stage, deployment_id, sleep: 4, count: 15) ⇒ DeploymentMonitor
constructor
A new instance of DeploymentMonitor.
- #on_failure(&block) ⇒ Object
- #on_success(&block) ⇒ Object
- #on_wait(&block) ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(stage, deployment_id, sleep: 4, count: 15) ⇒ DeploymentMonitor
Returns a new instance of DeploymentMonitor.
5 6 7 8 9 10 |
# File 'lib/hippo/deployment_monitor.rb', line 5 def initialize(stage, deployment_id, sleep: 4, count: 15) @stage = stage @deployment_id = deployment_id @sleep = sleep @count = count end |
Instance Method Details
#on_failure(&block) ⇒ Object
16 17 18 |
# File 'lib/hippo/deployment_monitor.rb', line 16 def on_failure(&block) @on_failure = block end |
#on_success(&block) ⇒ Object
20 21 22 |
# File 'lib/hippo/deployment_monitor.rb', line 20 def on_success(&block) @on_success = block end |
#on_wait(&block) ⇒ Object
12 13 14 |
# File 'lib/hippo/deployment_monitor.rb', line 12 def on_wait(&block) @on_wait = block end |
#wait ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hippo/deployment_monitor.rb', line 24 def wait count = 0 loop do sleep @sleep poll = Poll.new(@stage, @deployment_id) if poll.pending.empty? @on_success&.call(poll) return true else if count >= @count @on_failure&.call(poll) return false else count += 1 @on_wait&.call(poll) end end end end |