class SidekiqHero::NotifierWrapper

Attributes

job[R]
meta_data[R]
notifier[R]
queues[R]

Public Class Methods

new(job: nil, meta_data: nil) click to toggle source
# File lib/sidekiq_hero/notifier_wrapper.rb, line 7
def initialize(job: nil, meta_data: nil)
  @job = job
  @meta_data = meta_data
  @notifier = SidekiqHero.configuration.notifier_class.new
  @queues = SidekiqHero.configuration.queues
end

Public Instance Methods

call() click to toggle source
# File lib/sidekiq_hero/notifier_wrapper.rb, line 14
def call
  return unless monitor_this_worker?

  meta_data[:worker_time_out] = exceeded_max_time?

  notifier.notify(job, meta_data)
end

Private Instance Methods

exceeded_max_time?() click to toggle source
# File lib/sidekiq_hero/notifier_wrapper.rb, line 28
def exceeded_max_time?
  return false if sidekiq_hero_monitor_time.nil?

  meta_data[:total_time] > sidekiq_hero_monitor_time
end
monitor_queue?() click to toggle source
# File lib/sidekiq_hero/notifier_wrapper.rb, line 42
def monitor_queue?
  queues.include?(job['queue'])
end
monitor_this_worker?() click to toggle source
# File lib/sidekiq_hero/notifier_wrapper.rb, line 24
def monitor_this_worker?
  sidekiq_hero_monitor || monitor_queue? || exceeded_max_time?
end
sidekiq_hero_monitor() click to toggle source
# File lib/sidekiq_hero/notifier_wrapper.rb, line 38
def sidekiq_hero_monitor
  job['sidekiq_hero_monitor']
end
sidekiq_hero_monitor_time() click to toggle source
# File lib/sidekiq_hero/notifier_wrapper.rb, line 34
def sidekiq_hero_monitor_time
  job['sidekiq_hero_monitor_time']
end