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
36
37
|
# File 'lib/sidekiq/redis_connection.rb', line 10
def create(options = {})
symbolized_options = deep_symbolize_keys(options)
symbolized_options[:url] ||= determine_redis_provider
logger = symbolized_options.delete(:logger)
logger&.info { "Sidekiq #{Sidekiq::VERSION} connecting to Redis with options #{scrub(symbolized_options)}" }
raise "Sidekiq 7+ does not support Redis protocol 2" if symbolized_options[:protocol] == 2
safe = !!symbolized_options.delete(:cluster_safe)
raise ":nodes not allowed, Sidekiq is not safe to run on Redis Cluster" if !safe && symbolized_options.key?(:nodes)
size = symbolized_options.delete(:size) || 5
pool_timeout = symbolized_options.delete(:pool_timeout) || 1
pool_name = symbolized_options.delete(:pool_name)
symbolized_options[:timeout] ||= 3
redis_config = Sidekiq::RedisClientAdapter.new(symbolized_options)
ConnectionPool.new(timeout: pool_timeout, size: size, name: pool_name) do
redis_config.new_client
end
end
|