Class: SidekiqGlass::Worker Abstract
- Inherits:
-
Object
- Object
- SidekiqGlass::Worker
- Includes:
- Sidekiq::Worker
- Defined in:
- lib/sidekiq_glass/worker.rb
Overview
This class is abstract.
Subclass can be used for all workers in app
Note:
Please use the execute method instead of perform - because of the extra reentracy layer that has been introduced. Also if you define additional after_failure method you can handle any timeout (or any other) errors and ensure reentrancy for your workers
Base worker class for all other workers
end
Class Attribute Summary collapse
-
.logger ⇒ Logger
Logger that we want to use.
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
Class Attribute Details
.logger ⇒ Logger
Returns logger that we want to use.
32 33 34 |
# File 'lib/sidekiq_glass/worker.rb', line 32 def logger @logger ||= NullLogger.new end |
.timeout ⇒ Object
Returns the value of attribute timeout.
28 29 30 |
# File 'lib/sidekiq_glass/worker.rb', line 28 def timeout @timeout end |
Instance Method Details
#perform(*args) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sidekiq_glass/worker.rb', line 38 def perform(*args) if self.class.timeout ::SidekiqGlass::Timeout.perform(self.class.timeout) { execute(*args) } else execute(*args) end rescue => exception self.class.logger.fatal(exception) after_failure(*args) if respond_to?(:after_failure) raise exception end |