Class: Bosh::Director::EventLog::Stage
- Defined in:
- lib/bosh/director/event_log.rb
Instance Method Summary collapse
- #advance_and_track(task_name, &blk) ⇒ Object
-
#initialize(event_log, name, tags, total) ⇒ Stage
constructor
A new instance of Stage.
- #log_entry(entry) ⇒ Object
Constructor Details
#initialize(event_log, name, tags, total) ⇒ Stage
Returns a new instance of Stage.
58 59 60 61 62 63 64 65 |
# File 'lib/bosh/director/event_log.rb', line 58 def initialize(event_log, name, , total) @event_log = event_log @name = name @tags = @index = 0 @total = total @index_lock = Mutex.new end |
Instance Method Details
#advance_and_track(task_name, &blk) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bosh/director/event_log.rb', line 67 def advance_and_track(task_name, &blk) task = @index_lock.synchronize do @index += 1 Task.new(self, task_name, @index) end task.start begin blk.call(task) if blk rescue => e task.failed(e.to_s) raise end task.finish end |
#log_entry(entry) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/bosh/director/event_log.rb', line 83 def log_entry(entry) @event_log.log_entry({ :time => Time.now.to_i, :stage => @name, :tags => @tags, :total => @total, }.merge(entry)) end |