module Resque::Monitoring::Scheduler

Public Instance Methods

before_enqueue_record_last_execution() click to toggle source
# File lib/resque/monitoring/scheduler.rb, line 8
def before_enqueue_record_last_execution
  last_execution.report_new
end
scheduler_ok_when(&assert) click to toggle source
# File lib/resque/monitoring/scheduler.rb, line 12
def scheduler_ok_when(&assert)
  @assert = assert
  self
end
status() click to toggle source
# File lib/resque/monitoring/scheduler.rb, line 17
def status
  last_execution_date = last_execution.date
  return not_executed_yet unless last_execution_date.present?
  return Status.ok if assert.call(last_execution_date)
  executed_long_time_ago(last_execution_date)
end

Private Instance Methods

assert() click to toggle source
# File lib/resque/monitoring/scheduler.rb, line 33
def assert
  @assert ||= default_assert
end
default_assert() click to toggle source
# File lib/resque/monitoring/scheduler.rb, line 41
def default_assert
  Proc.new do |last_execution|
    last_execution >= DateTime.now - 15.minutes
  end
end
executed_long_time_ago(last_execution_date) click to toggle source
# File lib/resque/monitoring/scheduler.rb, line 29
def executed_long_time_ago(last_execution_date)
  Status.error("executed a long time ago, last execution: #{last_execution_date}")
end
last_execution() click to toggle source
# File lib/resque/monitoring/scheduler.rb, line 37
def last_execution
  @last_execution ||= LastExecution.by(name)
end
not_executed_yet() click to toggle source
# File lib/resque/monitoring/scheduler.rb, line 25
def not_executed_yet
  Status.error('not executed yet')
end