A few of my incredible co-workers over at Doximity released this
fantastic [simplekiq gem](GitHub - doximity/simplekiq: Sidekiq-based workflow orchestration library) to
orchestrate complex chains of jobs and batches. I'm really happy how
this turned out, and hope y'all enjoy it!
Any time that you find yourself needing to string together a long chain of jobs, particularly when there are multiple stages of Sidekiq-pro batches and callbacks involved, come home instead to the simple flavor of orchestrated job flow with Simplekiq.
class SomeOrchestrationJob < BaseJob
include Sidekiq::Worker
include Simplekiq::OrchestrationJob
def perform_orchestration(some_id)
@some_model = SomeModel.find(some_id) # 1.
run SomeInitialSetupJob, some_model.id # 2.
in_parallel do
some_related_models.each do |related_model|
run SomeParallelizableJob, related_model.id # 3.
end
end
Cheers,
Valentino