lib/simplekiq/batching_job.rb in simplekiq-0.0.3 vs lib/simplekiq/batching_job.rb in simplekiq-0.1.0
- old
+ new
@@ -106,23 +106,18 @@
def handle_batches(args)
if !batches.empty?
flush_batches(args)
else
- # Empty batches with no jobs will never invoke callbacks, so handle
- # that case by immediately manually invoking :complete & :success.
- on_complete(nil, {"args" => args}) if respond_to?(:on_complete)
- on_success(nil, {"args" => args}) if respond_to?(:on_success)
+ Simplekiq.run_empty_callbacks(self, args: args)
end
end
def flush_batches(args)
batch_job_class = self.class.const_get(BATCH_CLASS_NAME)
sidekiq_batch.description ||= "Simplekiq Batch Jobs for #{self.class.name}, args: #{args}"
- sidekiq_batch.on("death", self.class, "args" => args) if respond_to?(:on_death)
- sidekiq_batch.on("complete", self.class, "args" => args) if respond_to?(:on_complete)
- sidekiq_batch.on("success", self.class, "args" => args) if respond_to?(:on_success)
+ Simplekiq.auto_define_callbacks(sidekiq_batch, args: args, job: self)
sidekiq_batch.jobs do
batches.each do |job_args|
batch_job_class.perform_async(*job_args)
end