Welcome to mirror list, hosted at ThFree Co, Russian Federation.

until_executed.rb « strategies « duplicate_jobs « sidekiq_middleware « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5164b9942679f1ebc05e0ac7e4ce5aefba8264e2 (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
25
26
27
# frozen_string_literal: true

module Gitlab
  module SidekiqMiddleware
    module DuplicateJobs
      module Strategies
        # This strategy takes a lock before scheduling the job in a queue and
        # removes the lock after the job has executed preventing a new job to be queued
        # while a job is still executing.
        class UntilExecuted < Base
          extend ::Gitlab::Utils::Override

          include DeduplicatesWhenScheduling

          override :perform
          def perform(job)
            super

            yield

            duplicate_job.delete!
          end
        end
      end
    end
  end
end