-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hi, how are you?
First, thanks for all your work.
I need to trigger callbacks per job instance, as I'm trying below:
Workflow Root Job:
class CsvGenerator::BaseJob
include Sidekiq::Worker
sidekiq_options workflow: true, queue: :test
def on_workflow_complete
Rails.logger.info "[JobWorkflow] Callback Completed!"
end
def perform
# call child jobs
endCallback Registry:
Sidekiq::Hierarchy.callback_registry
.subscribe(Sidekiq::Hierarchy::Notifications::WORKFLOW_UPDATE,
Sidekiq::Hierarchy::WorkflowListener.new)Workflow Listener:
class Sidekiq::Hierarchy::WorkflowListener
def call(job, status, _old_status)
Rails.logger.info "[JobWorkflow] Job: #{job} Status: #{status}"
callback = :"on_workflow_#{status}"
job.send(callback) if job.respond_to?(callback)
end
endThe problem is that this line won't work: job.send(callback) if job.respond_to?(callback), because job is not our class, is a Sidekiq::Hierarchy::Workflow & Jobs...
Is there any way to get the original CsvGenerator::BaseJob instance from job inside Listener's call()?
Thanks.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels