diff options
Diffstat (limited to 'lib/gitlab/sidekiq_status.rb')
-rw-r--r-- | lib/gitlab/sidekiq_status.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/gitlab/sidekiq_status.rb b/lib/gitlab/sidekiq_status.rb index ae4aca7ff92..496ed9de828 100644 --- a/lib/gitlab/sidekiq_status.rb +++ b/lib/gitlab/sidekiq_status.rb @@ -50,6 +50,16 @@ module Gitlab end end + # Refreshes the timeout on the key if it exists + # + # jid = The Sidekiq job ID + # expire - The expiration time of the Redis key. + def self.expire(jid, expire = DEFAULT_EXPIRATION) + with_redis do |redis| + redis.expire(key_for(jid), expire) + end + end + # Returns true if all the given job have been completed. # # job_ids - The Sidekiq job IDs to check. @@ -132,7 +142,8 @@ module Gitlab Feature.enabled?(:use_primary_store_as_default_for_sidekiq_status) # TODO: Swap for Gitlab::Redis::SharedState after store transition # https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/923 - Gitlab::Redis::SidekiqStatus.with { |redis| yield redis } + # For now, we use SharedState to reduce amount of spawned connection to Redis Cluster during initialisation + Gitlab::Redis::SharedState.with { |redis| yield redis } else # Keep the old behavior intact if neither feature flag is turned on Sidekiq.redis { |redis| yield redis } # rubocop:disable Cop/SidekiqRedisCall |