Module: Joblin::Batching::Compat::ActiveJob
- Defined in:
- lib/joblin/batching/compat/active_job.rb
Defined Under Namespace
Modules: BatchAwareJob
Classes: ActiveJobCallbackWorker
Class Method Summary
collapse
Class Method Details
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/joblin/batching/compat/active_job.rb', line 93
def self.configure
::ActiveJob::Base.include BatchAwareJob
begin
ActiveSupport::Notifications.subscribe "discard.active_job" do |*args|
handle_job_death(args)
end
ActiveSupport::Notifications.subscribe "retry_stopped.active_job" do |*args|
handle_job_death(args)
end
rescue => err
Rails.logger.warn(err)
end
Batch::Callback.worker_class ||= ActiveJobCallbackWorker
end
|
.handle_job_death(job, error = nil) ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/joblin/batching/compat/active_job.rb', line 80
def self.handle_job_death(job, error = nil)
if job.is_a?(Array)
event = ActiveSupport::Notifications::Event.new(*job)
payload = event.payload
job = payload[:job].serialize
error = payload[:error]
end
if job["job_id"].present? && job["batch_id"].present?
Joblin::Batching::Batch.process_dead_job(job['batch_id'], job['job_id'])
end
end
|