module Sqeduler::Worker::Callbacks
Basic callbacks for worker events.
Public Instance Methods
perform(*args)
click to toggle source
Calls superclass method
# File lib/sqeduler/worker/callbacks.rb, line 7 def perform(*args) before_start duration = Benchmark.realtime { super } on_success(duration) rescue StandardError => e on_failure(e) raise end
Private Instance Methods
before_start()
click to toggle source
provides an oppurtunity to log when the job has started (maybe create a stateful db record for this job run?)
Calls superclass method
# File lib/sqeduler/worker/callbacks.rb, line 20 def before_start Service.logger.info "Starting #{self.class.name} at #{Time.now} in process ID #{Process.pid}" super if defined?(super) end
on_failure(e)
click to toggle source
callback for when failues in this job occur
Calls superclass method
# File lib/sqeduler/worker/callbacks.rb, line 32 def on_failure(e) Service.logger.error "#{self.class.name} failed with exception #{e}" super if defined?(super) end
on_success(total_time)
click to toggle source
callback for successful run of this job
Calls superclass method
# File lib/sqeduler/worker/callbacks.rb, line 26 def on_success(total_time) Service.logger.info "#{self.class.name} completed at #{Time.now}. Total time #{total_time}" super if defined?(super) end