module Sidekiq::Hierarchy
Constants
- VERSION
Attributes
callback_registry[RW]
Callbacks
Public Class Methods
current_job()
click to toggle source
Retrieves job for the current Sidekiq
job if previously set
# File lib/sidekiq/hierarchy.rb, line 51 def current_job Thread.current[:sidekiq_hierarchy_job] end
current_job=(job)
click to toggle source
Sets the job for the current fiber/worker
# File lib/sidekiq/hierarchy.rb, line 46 def current_job=(job) Thread.current[:sidekiq_hierarchy_job] = job end
current_workflow()
click to toggle source
Retrieves the current Sidekiq
workflow if previously set
# File lib/sidekiq/hierarchy.rb, line 41 def current_workflow Thread.current[:sidekiq_hierarchy_workflow] end
current_workflow=(workflow)
click to toggle source
Sets the workflow object for the current fiber/worker
# File lib/sidekiq/hierarchy.rb, line 36 def current_workflow=(workflow) Thread.current[:sidekiq_hierarchy_workflow] = workflow end
enabled?()
click to toggle source
Checks if tracking is enabled based on whether the workflow is known If disabled, all methods are no-ops
# File lib/sidekiq/hierarchy.rb, line 31 def enabled? !!current_workflow # without a workflow, we can't do anything end
publish(event, *args)
click to toggle source
# File lib/sidekiq/hierarchy.rb, line 103 def publish(event, *args) callback_registry.publish(event, *args) end
record_job_complete()
click to toggle source
# File lib/sidekiq/hierarchy.rb, line 79 def record_job_complete return unless enabled? && current_job current_job.complete! end
record_job_enqueued(job)
click to toggle source
Workflow
execution updates
# File lib/sidekiq/hierarchy.rb, line 58 def record_job_enqueued(job) return unless !!job['workflow'] if current_job.nil? # this is a root-level job, i.e., start of a workflow queued_job = Job.create(job['jid'], job) queued_job.enqueue! # initial status: enqueued elsif current_job.jid == job['jid'] # this is a job requeuing itself, ignore it else # this is an intermediate job, having both parent and children queued_job = Job.create(job['jid'], job) current_job.add_child(queued_job) queued_job.enqueue! # initial status: enqueued end end
record_job_failed()
click to toggle source
# File lib/sidekiq/hierarchy.rb, line 89 def record_job_failed return unless enabled? && current_job current_job.fail! end
record_job_requeued()
click to toggle source
# File lib/sidekiq/hierarchy.rb, line 84 def record_job_requeued return unless enabled? && current_job current_job.requeue! end
record_job_running()
click to toggle source
# File lib/sidekiq/hierarchy.rb, line 74 def record_job_running return unless enabled? && current_job current_job.run! end
redis=(conn)
click to toggle source
Global redis store – overrides default Sidekiq
redis
# File lib/sidekiq/hierarchy.rb, line 23 def redis=(conn) RedisConnection.redis = conn end
subscribe(event, callback)
click to toggle source
# File lib/sidekiq/hierarchy.rb, line 99 def subscribe(event, callback) callback_registry.subscribe(event, callback) end