Module: Simplekiq

Defined in:
lib/simplekiq/batching_job.rb,
lib/simplekiq.rb,
lib/simplekiq/version.rb,
lib/simplekiq/orchestration.rb,
lib/simplekiq/batch_tracker_job.rb,
lib/simplekiq/orchestration_job.rb,
lib/simplekiq/orchestration_executor.rb

Overview

This job serves two purposes:

  • TODO: It provides a convenient way to track top-level orchestration batches

  • The top-level orchestration batch would otherwise be empty (aside from child-batches) and all sidekiq-pro batches must have at least 1 job

Defined Under Namespace

Modules: BatchingJob, OrchestrationJob Classes: BaseBatch, BatchTrackerJob, Orchestration, OrchestrationExecutor

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.auto_define_callbacks(batch, args:, job:) ⇒ Object



21
22
23
24
25
# File 'lib/simplekiq.rb', line 21

def auto_define_callbacks(batch, args:, job:)
  batch.on("death", job.class, "args" => args) if job.respond_to?(:on_death)
  batch.on("complete", job.class, "args" => args) if job.respond_to?(:on_complete)
  batch.on("success", job.class, "args" => args) if job.respond_to?(:on_success)
end

.run_empty_callbacks(job, args:) ⇒ Object

Empty batches with no jobs will never invoke callbacks, so handle that case by immediately manually invoking :complete & :success.



16
17
18
19
# File 'lib/simplekiq.rb', line 16

def run_empty_callbacks(job, args:)
  job.on_complete(nil, {"args" => args}) if job.respond_to?(:on_complete)
  job.on_success(nil, {"args" => args}) if job.respond_to?(:on_success)
end