lib/sidekiq/job_alert/notifier.rb in sidekiq-job_alert-0.1.2 vs lib/sidekiq/job_alert/notifier.rb in sidekiq-job_alert-0.1.3
- old
+ new
@@ -11,11 +11,11 @@
@message = ''
end
def call
@message += make_dead_job_message
- @message += make_job_message('alert_total_waiting_jobs', 'all')
+ @message += make_all_job_message('alert_total_waiting_jobs')
keys = @slack_config[:alert_each_waiting_job].keys
keys.delete(:message)
keys.each do |key|
@message += make_job_message('alert_each_waiting_job', key)
end
@@ -29,9 +29,15 @@
private
def make_dead_job_message
cnt = Sidekiq::JobAlert::Queue.dead_job_cnt
cnt.positive? ? make_message('alert_dead_jobs', cnt) : ''
+ end
+
+ def make_all_job_message(type)
+ cnt = Sidekiq::JobAlert::Queue.all_job_cnt
+ limit = @slack_config[type.to_sym][:all][:limit].to_i
+ cnt > limit ? make_message(type, cnt) : ''
end
def make_job_message(type, queue_name)
cnt = Sidekiq::JobAlert::Queue.queue_job_cnt(queue_name)
limit = @slack_config[type.to_sym][queue_name.to_sym][:limit].to_i