Active Job Continuable¶ ↑
模块 Continuable 提供了跟踪作业进度并在中断时从上次中断的地方继续的能力。
将 ActiveJob::Continuable 混入您的作业以启用续传。
有关用法,请参阅 ActiveJob::Continuation。
方法
Attributes
| [RW] | resumptions | 作业已恢复的次数。 |
类公共方法
new(...) 链接
来源: 显示 | 在 GitHub 上
# File activejob/lib/active_job/continuable.rb, line 23 def initialize(...) super(...) self.resumptions = 0 self.continuation = Continuation.new(self, {}) end
实例公共方法
step(step_name, start: nil, isolated: false, &block) 链接
启动一个新的续传步骤
来源: 显示 | 在 GitHub 上
# File activejob/lib/active_job/continuable.rb, line 36 def step(step_name, start: nil, isolated: false, &block) unless block_given? 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 block = step_method.arity == 0 ? -> (_) { step_method.call } : step_method end checkpoint! if continuation.advanced? continuation.step(step_name, start: start, isolated: isolated, &block) end