module RocketJob::Plugins::Job::StateMachine
State machine for RocketJob::Job
Public Class Methods
pause_all()
click to toggle source
Pause all running jobs
# File lib/rocket_job/plugins/job/state_machine.rb, line 104 def self.pause_all running.each(&:pause!) end
resume_all()
click to toggle source
Resume all paused jobs
# File lib/rocket_job/plugins/job/state_machine.rb, line 109 def self.resume_all paused.each(&:resume!) end
Public Instance Methods
pausable?()
click to toggle source
All regular jobs can be paused or resumed whilst queued.
# File lib/rocket_job/plugins/job/state_machine.rb, line 115 def pausable? queued? || paused? || pausable end
Private Instance Methods
rocket_job_clear_completed_at()
click to toggle source
# File lib/rocket_job/plugins/job/state_machine.rb, line 161 def rocket_job_clear_completed_at self.completed_at = nil end
rocket_job_clear_exception()
click to toggle source
# File lib/rocket_job/plugins/job/state_machine.rb, line 150 def rocket_job_clear_exception self.completed_at = nil self.exception = nil self.worker_name = nil end
rocket_job_clear_started_at()
click to toggle source
# File lib/rocket_job/plugins/job/state_machine.rb, line 165 def rocket_job_clear_started_at self.started_at = nil self.worker_name = nil end
rocket_job_destroy_on_complete()
click to toggle source
# File lib/rocket_job/plugins/job/state_machine.rb, line 170 def rocket_job_destroy_on_complete destroy if destroy_on_complete && !new_record? end
rocket_job_increment_failure_count()
click to toggle source
# File lib/rocket_job/plugins/job/state_machine.rb, line 146 def rocket_job_increment_failure_count self.failure_count += 1 end
rocket_job_mark_complete()
click to toggle source
# File lib/rocket_job/plugins/job/state_machine.rb, line 142 def rocket_job_mark_complete self.percent_complete = 100 end
rocket_job_set_completed_at()
click to toggle source
# File lib/rocket_job/plugins/job/state_machine.rb, line 156 def rocket_job_set_completed_at self.completed_at = Time.now self.worker_name = nil end
rocket_job_set_exception(worker_name = nil, exc_or_message = nil)
click to toggle source
Sets the exception child object for this job based on the supplied Exception instance or message
# File lib/rocket_job/plugins/job/state_machine.rb, line 123 def rocket_job_set_exception(worker_name = nil, exc_or_message = nil) if exc_or_message.is_a?(Exception) self.exception = JobException.from_exception(exc_or_message) exception.worker_name = worker_name else build_exception( class_name: "RocketJob::JobException", message: exc_or_message, backtrace: [], worker_name: worker_name ) end end
rocket_job_set_started_at(worker_name = nil)
click to toggle source
# File lib/rocket_job/plugins/job/state_machine.rb, line 137 def rocket_job_set_started_at(worker_name = nil) self.started_at = Time.now self.worker_name = worker_name if worker_name end