Class: Bosh::Deployer::DeployerRenderer
- Inherits:
-
Object
- Object
- Bosh::Deployer::DeployerRenderer
- Defined in:
- lib/bosh/deployer/deployer_renderer.rb
Constant Summary collapse
- DEFAULT_POLL_INTERVAL =
0.1
Instance Method Summary collapse
- #duration ⇒ Object
- #enter_stage(stage, total) ⇒ Object
- #finish(state) ⇒ Object
-
#initialize(event_log_renderer) ⇒ DeployerRenderer
constructor
A new instance of DeployerRenderer.
- #start ⇒ Object
- #update(state, task) ⇒ Object
Constructor Details
#initialize(event_log_renderer) ⇒ DeployerRenderer
Returns a new instance of DeployerRenderer.
5 6 7 8 |
# File 'lib/bosh/deployer/deployer_renderer.rb', line 5 def initialize(event_log_renderer) @event_log_renderer = event_log_renderer @index = 0 end |
Instance Method Details
#duration ⇒ Object
47 48 49 |
# File 'lib/bosh/deployer/deployer_renderer.rb', line 47 def duration @event_log_renderer.duration end |
#enter_stage(stage, total) ⇒ Object
24 25 26 27 28 |
# File 'lib/bosh/deployer/deployer_renderer.rb', line 24 def enter_stage(stage, total) @stage = stage @total = total @index = 0 end |
#finish(state) ⇒ Object
19 20 21 22 |
# File 'lib/bosh/deployer/deployer_renderer.rb', line 19 def finish(state) @thread.kill @event_log_renderer.finish(state) end |
#start ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/bosh/deployer/deployer_renderer.rb', line 10 def start @thread = Thread.new do loop do @event_log_renderer.refresh sleep(interval_poll) end end end |
#update(state, task) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bosh/deployer/deployer_renderer.rb', line 30 def update(state, task) event = { 'time' => Time.now, 'stage' => @stage, 'task' => task, 'tags' => [], 'index' => @index + 1, 'total' => @total, 'state' => state.to_s, 'progress' => state == :finished ? 100 : 0, } @event_log_renderer.add_output(JSON.generate(event)) @index += 1 if state == :finished end |