Class: OKComputer::DelayedJobBackedUpCheck

Inherits:
SizeThresholdCheck show all
Defined in:
lib/okcomputer/built_in_checks/delayed_job_backed_up_check.rb

Constant Summary

Constants inherited from Check

Check::CALL_DEPRECATION_MESSAGE, Check::CheckNotDefined

Instance Attribute Summary collapse

Attributes inherited from SizeThresholdCheck

#name, #size_proc

Attributes inherited from Check

#failure_occurred, #message, #registrant_name

Instance Method Summary collapse

Methods inherited from SizeThresholdCheck

#check

Methods inherited from Check

#clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text

Constructor Details

#initialize(priority, threshold) ⇒ DelayedJobBackedUpCheck

Public: Initialize a check for backed-up Delayed Job jobs

priority - Which priority (or greater) to check for threshold - An Integer to compare the jobs count against to consider it backed up

Example:

check = new(10, 50)
# => The check will look for jobs with priority between
# 0 and 10, considering the jobs as backed up if there
# are more than 50 of them


17
18
19
20
21
# File 'lib/okcomputer/built_in_checks/delayed_job_backed_up_check.rb', line 17

def initialize(priority, threshold)
  self.priority = Integer(priority)
  self.threshold = Integer(threshold)
  self.name = "Delayed Jobs within priority '#{priority}'"
end

Instance Attribute Details

#priorityObject

Returns the value of attribute priority.



3
4
5
# File 'lib/okcomputer/built_in_checks/delayed_job_backed_up_check.rb', line 3

def priority
  @priority
end

#thresholdObject

Returns the value of attribute threshold.



4
5
6
# File 'lib/okcomputer/built_in_checks/delayed_job_backed_up_check.rb', line 4

def threshold
  @threshold
end

Instance Method Details

#sizeObject

Public: How many delayed jobs are pending within the given priority



24
25
26
# File 'lib/okcomputer/built_in_checks/delayed_job_backed_up_check.rb', line 24

def size
  Delayed::Job.where("priority <= ?", priority).where(:locked_at => nil, :last_error => nil).count
end