about summary refs log tree commit diff
path: root/app/lib/admin/system_check/sidekiq_process_check.rb
blob: d577b3bf3c51c73c860cd232e5f009896fa8a6d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

class Admin::SystemCheck::SidekiqProcessCheck < Admin::SystemCheck::BaseCheck
  SIDEKIQ_QUEUES = %w(
    default
    push
    mailers
    pull
    scheduler
    ingress
  ).freeze

  def skip?
    !current_user.can?(:view_devops)
  end

  def pass?
    missing_queues.empty?
  end

  def message
    Admin::SystemCheck::Message.new(:sidekiq_process_check, missing_queues.join(', '))
  end

  private

  def missing_queues
    @missing_queues ||= Sidekiq::ProcessSet.new.reduce(SIDEKIQ_QUEUES) { |queues, process| queues - process['queues'] }
  end
end