Module: Que::ActiveJob::WrapperExtensions::InstanceMethods
- Included in:
- ActiveJob::QueueAdapters::QueAdapter::JobWrapper
- Defined in:
- lib/que/active_job/extensions.rb
Instance Method Summary collapse
-
#attrs ⇒ Object
The Rails adapter (built against a pre-1.0 version of this gem) assumes that it can access a job’s id via job.attrs.
- #run(args) ⇒ Object
Instance Method Details
#attrs ⇒ Object
The Rails adapter (built against a pre-1.0 version of this gem) assumes that it can access a job’s id via job.attrs. So, oblige it.
76 77 78 |
# File 'lib/que/active_job/extensions.rb', line 76 def attrs {"job_id" => que_attrs[:id]} end |
#run(args) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/que/active_job/extensions.rb', line 80 def run(args) # Our ActiveJob extensions expect to be able to operate on the actual # job object, but there's no way to access it through ActiveJob. So, # scope it to the current thread. It's a bit messy, but it's the best # option under the circumstances (doesn't require hacking ActiveJob in # any more extensive way). # There's no reason this logic should ever nest, because it wouldn't # make sense to run a worker inside of a job, but even so, assert that # nothing absurd is going on. Que.assert NilClass, Thread.current[:que_current_job] begin Thread.current[:que_current_job] = self # We symbolize the args hash but ActiveJob doesn't like that :/ super(args.deep_stringify_keys) ensure # Also assert that the current job state was only removed now, but # unset the job first so that an assertion failure doesn't mess up # the state any more than it already has. current = Thread.current[:que_current_job] Thread.current[:que_current_job] = nil Que.assert(self, current) end end |