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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/job_waiter.rb')
-rw-r--r--lib/gitlab/job_waiter.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/gitlab/job_waiter.rb b/lib/gitlab/job_waiter.rb
index 880b112d815..e53bfb40654 100644
--- a/lib/gitlab/job_waiter.rb
+++ b/lib/gitlab/job_waiter.rb
@@ -22,14 +22,16 @@ module Gitlab
STARTED_METRIC = :gitlab_job_waiter_started_total
TIMEOUTS_METRIC = :gitlab_job_waiter_timeouts_total
- def self.notify(key, jid)
+ # This TTL needs to be long enough to allow whichever Sidekiq job calls
+ # JobWaiter#wait to reach BLPOP.
+ DEFAULT_TTL = 6.hours.to_i
+
+ def self.notify(key, jid, ttl: DEFAULT_TTL)
Gitlab::Redis::SharedState.with do |redis|
# Use a Redis MULTI transaction to ensure we always set an expiry
redis.multi do |multi|
multi.lpush(key, jid)
- # This TTL needs to be long enough to allow whichever Sidekiq job calls
- # JobWaiter#wait to reach BLPOP.
- multi.expire(key, 6.hours.to_i)
+ multi.expire(key, ttl)
end
end
end
@@ -42,6 +44,10 @@ module Gitlab
"#{KEY_PREFIX}:#{SecureRandom.uuid}"
end
+ def self.delete_key(key)
+ Gitlab::Redis::SharedState.with { |redis| redis.del(key) } if key?(key)
+ end
+
attr_reader :key, :finished, :worker_label
attr_accessor :jobs_remaining