Class: Bosh::Director::EventLog::Stage

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/event_log.rb

Instance Method Summary collapse

Constructor Details

#initialize(event_log, name, tags, total) ⇒ Stage

Returns a new instance of Stage.



82
83
84
85
86
87
88
89
# File 'lib/bosh/director/event_log.rb', line 82

def initialize(event_log, name, tags, total)
  @event_log = event_log
  @name = name
  @tags = tags
  @index = 0
  @total = total
  @index_lock = Mutex.new
end

Instance Method Details

#advance_and_track(task_name, &blk) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/bosh/director/event_log.rb', line 91

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



107
108
109
110
111
112
113
114
# File 'lib/bosh/director/event_log.rb', line 107

def log_entry(entry)
  @event_log.log_entry({
    :time => Time.now.to_i,
    :stage => @name,
    :tags => @tags,
    :total => @total,
  }.merge(entry))
end