Class: Cyclid::API::Plugins::Worker::Local
- Inherits:
-
Object
- Object
- Cyclid::API::Plugins::Worker::Local
- Includes:
- Sidekiq::Worker
- Defined in:
- app/cyclid/plugins/dispatcher/local.rb
Overview
Local Sidekiq based worker
Instance Method Summary collapse
-
#perform(job, job_id, callback_object) ⇒ Object
Run a job Runner asynchronously.
Instance Method Details
#perform(job, job_id, callback_object) ⇒ Object
Run a job Runner asynchronously
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'app/cyclid/plugins/dispatcher/local.rb', line 148 def perform(job, job_id, callback_object) begin # Unserialize the callback object, if there is one callback = callback_object.nil? ? nil : Oj.load(callback_object) notifier = Notifier::Local.new(job_id, callback) rescue StandardError => ex Cyclid.logger.debug "couldn't create notifier: #{ex}" return false end begin runner = Cyclid::API::Job::Runner.new(job_id, job, notifier) success = runner.run rescue StandardError => ex Cyclid.logger.error "local Sidekiq Worker failed: #{ex}" Cyclid.logger.debug ex.backtrace.join("\n") success = false end # Notify completion notifier.completion(success) return success ensure ::ActiveRecord::Base.clear_active_connections! end |