Sha256: 287620df6b9e31dce21bde914f657d1c4b7788478dddd3a70a83e95edf122a69
Contents?: true
Size: 1.42 KB
Versions: 54
Compression:
Stored size: 1.42 KB
Contents
require 'honeybadger/plugin' require 'honeybadger/ruby' module Honeybadger module Plugins module Faktory class Middleware def call(worker, job) Honeybadger.clear! yield end end Plugin.register do requirement { defined?(::Faktory) } execution do ::Faktory.configure_worker do |faktory| faktory.worker_middleware do |chain| chain.prepend Middleware end end ::Faktory.configure_worker do |faktory| faktory.error_handlers << lambda do |ex, params| opts = {parameters: params} if job = params[:job] if (threshold = config[:'faktory.attempt_threshold'].to_i) > 0 # If job.failure is nil, it is the first attempt. The first # retry has a job.failure.retry_count of 0, which would be # the second attempt in our case. retry_count = job.dig('failure', 'retry_count') attempt = retry_count ? retry_count + 1 : 0 limit = [job['retry'].to_i, threshold].min return if attempt < limit end opts[:component] = job['jobtype'] opts[:action] = 'perform' end Honeybadger.notify(ex, opts) end end end end end end end
Version data entries
54 entries across 54 versions & 1 rubygems