Module: WorkerGlass::Reentrancy

Defined in:
lib/worker_glass/reentrancy.rb

Overview

Note:

If will reraise a given error - it does not silence them

This module provides a reentrancy functionality for background processing engine

Examples:

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

Instance Method Summary collapse

Instance Method Details

#perform(*args) ⇒ Object

Executes a business logic with additional timeouts

Parameters:

  • args

    Any arguments that we passed when scheduling a background job



22
23
24
25
26
27
28
# 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