class Sidekiq::Monitor::Event
Public Class Methods
create_or_update_with(worker, message, queue)
click to toggle source
# File lib/sidekiq/monitor/models/event.rb, line 17 def create_or_update_with(worker, message, queue) transaction do find_or_initialize_by_id(message['monitor_id']).tap do |e| e.started_at = Time.now e.retry_count = message['retry_count'].to_i + 1 if message.has_key?('retry_count') e.worker_class = worker.class.name e.args = message['args'] e.jid = message['jid'] e.queue = queue e.save message['monitor_id'] ||= e.id end end end
find_or_initialize_by_id(id, options = {}, &block)
click to toggle source
Calls superclass method
# File lib/sidekiq/monitor/models/event.rb, line 33 def find_or_initialize_by_id(id, options = {}, &block) id.nil? ? new(options, &block) : super end
Public Instance Methods
error(exception)
click to toggle source
# File lib/sidekiq/monitor/models/event.rb, line 53 def error(exception) update_attribute(:exception, { class: exception.class.name, backtrace: exception.backtrace, message: exception.message }) end
finish()
click to toggle source
# File lib/sidekiq/monitor/models/event.rb, line 49 def finish update_attribute(:runtime, Time.now - started_at) end
finished?()
click to toggle source
# File lib/sidekiq/monitor/models/event.rb, line 39 def finished? !!finished_at end
finished_at()
click to toggle source
# File lib/sidekiq/monitor/models/event.rb, line 43 def finished_at if runtime? started_at + runtime.seconds end end
Protected Instance Methods
assign_revision()
click to toggle source
# File lib/sidekiq/monitor/models/event.rb, line 63 def assign_revision self.revision = Sidekiq::Monitor.current_revision end