summaryrefslogtreecommitdiff
path: root/lib/gitlab/sidekiq_middleware/duplicate_jobs.rb
blob: 7a77a56d642c0cdfdeb114e1f992de52a94749bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

require 'digest'

module Gitlab
  module SidekiqMiddleware
    module DuplicateJobs
      DROPPABLE_QUEUES = Set.new([
        Namespaces::RootStatisticsWorker.queue,
        Namespaces::ScheduleAggregationWorker.queue
      ]).freeze

      def self.drop_duplicates?(queue_name)
        Feature.enabled?(:drop_duplicate_sidekiq_jobs) ||
          drop_duplicates_for_queue?(queue_name)
      end

      private_class_method def self.drop_duplicates_for_queue?(queue_name)
        DROPPABLE_QUEUES.include?(queue_name) &&
          Feature.enabled?(:drop_duplicate_sidekiq_jobs_for_queue)
      end
    end
  end
end