Module: Resque::Plugins::DisableJob

Defined in:
lib/resque/plugins/disable_job.rb,
lib/resque/plugins/disable_job/job.rb,
lib/resque/plugins/disable_job/rule.rb,
lib/resque/plugins/disable_job/stats.rb

Overview

DisableJob

This class handles the main logic of the DisableJob plugin. We can configure a job to be allowed to be disabled, set a job to be disabled or enable a job, and we can see the status of the currently disabled jobs.

Defined Under Namespace

Classes: Job, Rule, Stats

Constant Summary collapse

MAX_JOB_RULES =
10
DEFAULT_TIMEOUT =

seconds

3600

Instance Method Summary collapse

Instance Method Details

#before_perform_allow_disable_job(*args) ⇒ Object



17
18
19
20
21
# File 'lib/resque/plugins/disable_job.rb', line 17

def before_perform_allow_disable_job(*args)
  if Job.disabled?(name, args)
    disable_job_handler("Skipped running job #{name}(#{args})", args)
  end
end

#disable(specific_args = [], timeout = DEFAULT_TIMEOUT) ⇒ Object



28
29
30
# File 'lib/resque/plugins/disable_job.rb', line 28

def disable(specific_args = [], timeout = DEFAULT_TIMEOUT)
  Job.disable_job(name, specific_args: specific_args, timeout: timeout)
end

#disable_job_handler(message, *_args) ⇒ Object

Override this if you want custom processing

Raises:

  • (Resque::Job::DontPerform)


24
25
26
# File 'lib/resque/plugins/disable_job.rb', line 24

def disable_job_handler(message, *_args)
  raise Resque::Job::DontPerform, message
end

#enable(specific_args = []) ⇒ Object



32
33
34
# File 'lib/resque/plugins/disable_job.rb', line 32

def enable(specific_args = [])
  Job.enable_job(name, specific_args: specific_args)
end

#enable_allObject



36
37
38
# File 'lib/resque/plugins/disable_job.rb', line 36

def enable_all
  Job.enable_all(name)
end