Module: ActiveJob::Execution
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::ActiveSupport::Concern
|
|
Instance Chain:
|
|
Defined in: | activejob/lib/active_job/execution.rb |
Overview
Provides methods to execute jobs immediately, and wraps job execution so that exceptions configured with rescue_from are handled.
::ActiveSupport::Rescuable
- Attributes & Methods
Class Method Summary
::ActiveSupport::Concern
- Extended
class_methods | Define class methods from given block. |
included | Evaluate given block in context of base class, so that you can write class macros here. |
prepended | Evaluate given block in context of base class, so that you can write class macros here. |
Instance Method Summary
- #perform
-
#perform_now
Performs the job immediately.
::ActiveSupport::Rescuable
- Included
#rescue_with_handler | Delegates to the class method, but uses the instance as the subject for rescue_from handlers (method calls, |
Class Attribute Details
.rescue_handlers (rw)
[ GitHub ]# File 'activesupport/lib/active_support/rescuable.rb', line 15
class_attribute :rescue_handlers, default: []
.rescue_handlers? ⇒ Boolean
(rw)
[ GitHub ]
# File 'activesupport/lib/active_support/rescuable.rb', line 15
class_attribute :rescue_handlers, default: []
Instance Attribute Details
#rescue_handlers (rw)
[ GitHub ]# File 'activesupport/lib/active_support/rescuable.rb', line 15
class_attribute :rescue_handlers, default: []
#rescue_handlers? ⇒ Boolean
(rw)
[ GitHub ]
# File 'activesupport/lib/active_support/rescuable.rb', line 15
class_attribute :rescue_handlers, default: []
Instance Method Details
#perform
[ GitHub ]# File 'activejob/lib/active_job/execution.rb', line 60
def perform(*) fail NotImplementedError end
#perform_now
Performs the job immediately. The job is not sent to the queuing adapter but directly executed by blocking the execution of others until it’s finished. perform_now
returns the value of your job’s #perform method.
class MyJob < ActiveJob::Base
def perform
"Hello World!"
end
end
puts MyJob.new(*args).perform_now # => "Hello World!"
# File 'activejob/lib/active_job/execution.rb', line 45
def perform_now # Guard against jobs that were persisted before we started counting executions by zeroing out nil counters self.executions = (executions || 0) + 1 deserialize_arguments_if_needed _perform_job rescue Exception => exception handled = rescue_with_handler(exception) return handled if handled run_after_discard_procs(exception) raise end