-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsimplekiq.rb
27 lines (23 loc) · 959 Bytes
/
simplekiq.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true
require "sidekiq"
require "sidekiq-pro"
require "simplekiq/orchestration_executor"
require "simplekiq/orchestration"
require "simplekiq/orchestration_job"
require "simplekiq/batching_job"
require "simplekiq/batch_tracker_job"
module Simplekiq
class << self
# Empty batches with no jobs will never invoke callbacks, so handle
# that case by immediately manually invoking :complete & :success.
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
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
end
end