Sha256: bcbf3cdaeeb36020a4290ccdc0c86b1570102073a9f42e484c106d7fed3ad9b3

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 Bytes

Contents

module WorkerGlass
  # 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
  module Reentrancy
    # Executes a business logic with additional timeouts
    # @param args Any arguments that we passed when scheduling a background job
    def perform(*args)
      super
    rescue => exception
      WorkerGlass.logger.fatal(exception)
      after_failure(*args)
      raise exception
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
worker-glass-0.2.2 lib/worker_glass/reentrancy.rb
worker-glass-0.2.1 lib/worker_glass/reentrancy.rb
worker-glass-0.2.0 lib/worker_glass/reentrancy.rb