module WorkerGlass::Reentrancy
This module provides a reentrancy functionality for background processing engine @note If will reraise a given error - it does not silence them @example Example usage with Sidekiq - if something fails, after_failure will be executed
class Worker include Sidekiq::Worker prepend WorkerGlass::Reentrancy def perform(*args) FailingService.new.run(*args) end def after_failure(*args) FailingService.new.reset(*args) end end
Public Instance Methods
perform(*args)
click to toggle source
Executes a business logic with additional timeouts @param args Any arguments that we passed when scheduling a background job
Calls superclass method
# File lib/worker_glass/reentrancy.rb, line 22 def perform(*args) super rescue StandardError => e WorkerGlass.logger.fatal(e) after_failure(*args) raise e end