breamware / sidekiq-batch

Sidekiq Batch Jobs Implementation
MIT License
357 stars 95 forks source link

Add support for on_death callback #51

Closed bkazez closed 2 years ago

bkazez commented 3 years ago

Sidekiq Pro has a death callback:

Sidekiq can notify you when a Batch is complete or successful with batch.on(event, klass, options={}):

  1. complete - when all jobs in the batch have run once, successful or not.
  2. success - when all jobs in the batch have completed successfully.
  3. death - the first time a batch job dies

Regarding success, if a job fails continually it's possible the success event will never fire. If a job fails all retries and dies, it will fire any :death callbacks. The :death callback is always fired for first job in the batch that fails and does not retry. Even if you configure jobs to disable retries or job death, it will still fire the :death callback.

:death and :success are not mutually exclusive but the death callback firing means that the batch will not fire success without manual intervention. If you deploy a fix and manually re-enqueue a dead batch job, the batch can still fire :success.

But sidekiq-batch (lib/sidekiq/batch/callback.rb:8) silently fails if :death is passed.

github-actions[bot] commented 2 years ago

Stale issue message

bkazez commented 2 years ago

Can this be reopened? I think it is a valid feature given that sidekiq-batch purports to match the API of Sidekiq Pro.