module ActiveJob::Continuable
Active Job Continuable
Mix ActiveJob::Continuable
into your job to enable continuations.
See ActiveJob::Continuation
for usage. # The Continuable module provides the ability to track the progress of your jobs, and continue from where they left off if interrupted.
Constants
Public instance methods
Source code GitHub
# File activejob/lib/active_job/continuable.rb, line 45
def deserialize(job_data)
super
@continuation = Continuation.new(self, job_data.fetch(CONTINUATION_KEY, {}))
end
Source code GitHub
# File activejob/lib/active_job/continuable.rb, line 41
def serialize
super.merge(CONTINUATION_KEY => continuation.to_h)
end
Source code GitHub
# File activejob/lib/active_job/continuable.rb, line 23
def step(step_name, start: nil, &block)
continuation.step(step_name, start: start) do |step|
if block_given?
block.call(step)
else
step_method = method(step_name)
raise ArgumentError, "Step method '#{step_name}' must accept 0 or 1 arguments" if step_method.arity > 1
if step_method.parameters.any? { |type, name| type == :key || type == :keyreq }
raise ArgumentError, "Step method '#{step_name}' must not accept keyword arguments"
end
step_method.arity == 0 ? step_method.call : step_method.call(step)
end
end
end