Class: Wurk::Batch::CallbackJob

Inherits:
Object
  • Object
show all
Includes:
Job
Defined in:
lib/wurk/batch/callback_job.rb

Overview

Worker that runs a single batch callback. The target spec is one of:

"MyCallback"      → MyCallback.new.on_<event>(status, options)
"MyCallback#done" → MyCallback.new.done(status, options)
"#done"           → <batch callback_class>.new.done(status, options)

The class-less form takes its class from the batch's callback_class (spec §2.2), read from b-<bid> at run time — the spec travels through the job payload as a plain String, so nothing here depends on anything that a JSON round trip could lose.

Failures inside the callback retry like any ordinary job — callbacks MUST be idempotent.

Spec: docs/target/sidekiq-pro.md §2.4.

Defined Under Namespace

Classes: UnresolvableTarget

Constant Summary

Constants included from Job

Job::InterruptHandler, Job::Iterable, Job::Setter

Instance Method Summary collapse

Methods included from Job

clear_all, drain_all, included, jobs

Instance Method Details

#perform(bid, target_spec, event, options) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/wurk/batch/callback_job.rb', line 39

def perform(bid, target_spec, event, options)
  klass, method = resolve(bid, target_spec.to_s, event)
  instance = klass.new
  unless instance.respond_to?(method)
    raise UnresolvableTarget, "batch #{bid}: #{klass}##{method} is not a public method"
  end

  instance.public_send(method, Wurk::Batch::Status.new(bid), options || {})
end