blob: b66a5e70f56279ed72d2b5d8b43872778f9e50b8 (
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
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
require 'gitlab/redis'
Redis.raise_deprecations = true unless Rails.env.production?
# rubocop:disable Gitlab/NoCodeCoverageComment
# :nocov: This snippet is for local development only, reloading in specs would raise NameError
if Rails.env.development?
# reset all pools in the event of a reload
# This makes sure that there are no stale references to classes in the `Gitlab::Redis` namespace
# that also got reloaded.
Gitlab::Application.config.to_prepare do
Gitlab::Redis::ALL_CLASSES.each do |redis_instance|
redis_instance.instance_variable_set(:@pool, nil)
end
Rails.cache = ActiveSupport::Cache::RedisCacheStore.new(**Gitlab::Redis::Cache.active_support_config)
end
end
# :nocov:
# rubocop:enable Gitlab/NoCodeCoverageComment
Redis::Client.prepend(Gitlab::Instrumentation::RedisInterceptor)
Redis::Cluster::NodeLoader.prepend(Gitlab::Patch::NodeLoader)
Redis::Cluster.prepend(Gitlab::Patch::RedisCluster)
# Make sure we initialize a Redis connection pool before multi-threaded
# execution starts by
# 1. Sidekiq
# 2. Rails.cache
# 3. HTTP clients
Gitlab::Redis::ALL_CLASSES.each do |redis_instance|
redis_instance.with { nil }
end
|