Module: ActiveJob::Continuable
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::ActiveSupport::Concern
|
|
Defined in: | activejob/lib/active_job/continuable.rb |
Overview
Mix Continuable
into your job to enable continuations.
See 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.
Constant Summary
-
CONTINUATION_KEY =
# File 'activejob/lib/active_job/continuable.rb', line 14"continuation"
Class Method Summary
::ActiveSupport::Concern
- Extended
class_methods | Define class methods from given block. |
included | Evaluate given block in context of base class, so that you can write class macros here. |
prepended | Evaluate given block in context of base class, so that you can write class macros here. |
append_features, prepend_features |
Instance Method Summary
DSL Calls
included
[ GitHub ]16 17 18 19 20 21
# File 'activejob/lib/active_job/continuable.rb', line 16
included do retry_on Continuation::Interrupt, attempts: :unlimited retry_on Continuation::AfterAdvancingError, attempts: :unlimited around_perform :continue end
Instance Method Details
#continuation (private)
[ GitHub ]# File 'activejob/lib/active_job/continuable.rb', line 51
def continuation @continuation ||= Continuation.new(self, {}) end
#continue(&block) (private)
[ GitHub ]# File 'activejob/lib/active_job/continuable.rb', line 55
def continue(&block) continuation.continue(&block) end
#deserialize(job_data)
[ 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
#serialize
[ GitHub ]# File 'activejob/lib/active_job/continuable.rb', line 41
def serialize super.merge(CONTINUATION_KEY => continuation.to_h) end
#step(step_name, start: nil, &block)
[ 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