class Taskinator::Task::Job
a task which invokes the specified background job the args must be intrinsic types, since they are serialized to YAML
Attributes
args[R]
definition[R]
job[R]
Public Class Methods
new(process, job, args, options={})
click to toggle source
Calls superclass method
Taskinator::Task::new
# File lib/taskinator/task.rb, line 214 def initialize(process, job, args, options={}) super(process, options) @definition = process.definition # for convenience raise ArgumentError, 'job' if job.nil? raise ArgumentError, 'job' unless job.methods.include?(:perform) || job.instance_methods.include?(:perform) @job = job @args = args end
Public Instance Methods
accept(visitor)
click to toggle source
Calls superclass method
Taskinator::Task#accept
# File lib/taskinator/task.rb, line 251 def accept(visitor) super visitor.visit_type(:definition) visitor.visit_type(:job) visitor.visit_args(:args) end
enqueue()
click to toggle source
# File lib/taskinator/task.rb, line 225 def enqueue Taskinator.queue.enqueue_task(self) end
inspect()
click to toggle source
# File lib/taskinator/task.rb, line 258 def inspect %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} uuid="#{uuid}", job=#{job}, args=#{args}, current_state=:#{current_state}>) end
start()
click to toggle source
# File lib/taskinator/task.rb, line 229 def start # NNB: if other job types are required, may need to implement how they get invoked here! # FIXME: possible implement using ActiveJob instead, so it doesn't matter how the worker is implemented if job.respond_to?(:perform) # resque job.perform(*args) else # delayedjob and sidekiq job.new.perform(*args) end # ASSUMPTION: when the job returns, the task is considered to be complete complete! rescue => e Taskinator.logger.error(e) Taskinator.logger.debug(e.backtrace) fail!(e) raise e end