chore: Add fail safes for Redis connections (#2016)
This commit is contained in:
@@ -4,7 +4,3 @@ redis = Rails.env.test? ? MockRedis.new : Redis.new(Redis::Config.app)
|
|||||||
# Add here as you use it for more features
|
# Add here as you use it for more features
|
||||||
# Used for Round Robin, Conversation Emails & Online Presence
|
# Used for Round Robin, Conversation Emails & Online Presence
|
||||||
$alfred = Redis::Namespace.new('alfred', redis: redis, warning: true)
|
$alfred = Redis::Namespace.new('alfred', redis: redis, warning: true)
|
||||||
|
|
||||||
# https://github.com/mperham/sidekiq/issues/4591
|
|
||||||
# TODO once sidekiq remove we can remove this
|
|
||||||
Redis.exists_returns_integer = false
|
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ module Redis::Config
|
|||||||
def base_config
|
def base_config
|
||||||
{
|
{
|
||||||
url: ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379'),
|
url: ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379'),
|
||||||
password: ENV.fetch('REDIS_PASSWORD', nil).presence
|
password: ENV.fetch('REDIS_PASSWORD', nil).presence,
|
||||||
|
reconnect_attempts: 2,
|
||||||
|
network_timeout: 5
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ describe ::Redis::Config do
|
|||||||
|
|
||||||
it 'checks for app redis config' do
|
it 'checks for app redis config' do
|
||||||
app_config = described_class.app
|
app_config = described_class.app
|
||||||
expect(app_config.keys).to match_array([:url, :password])
|
expect(app_config.keys).to match_array([:url, :password, :network_timeout, :reconnect_attempts])
|
||||||
expect(app_config[:url]).to eq(redis_url)
|
expect(app_config[:url]).to eq(redis_url)
|
||||||
expect(app_config[:password]).to eq(redis_pasword)
|
expect(app_config[:password]).to eq(redis_pasword)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'checks for sidekiq redis config' do
|
it 'checks for sidekiq redis config' do
|
||||||
sidekiq_config = described_class.sidekiq
|
sidekiq_config = described_class.sidekiq
|
||||||
expect(sidekiq_config.keys).to match_array([:url, :password, :size])
|
expect(sidekiq_config.keys).to match_array([:url, :password, :size, :network_timeout, :reconnect_attempts])
|
||||||
expect(sidekiq_config[:url]).to eq redis_url
|
expect(sidekiq_config[:url]).to eq redis_url
|
||||||
expect(sidekiq_config[:password]).to eq redis_pasword
|
expect(sidekiq_config[:password]).to eq redis_pasword
|
||||||
expect(sidekiq_config[:size]).to eq described_class::SIDEKIQ_SIZE
|
expect(sidekiq_config[:size]).to eq described_class::SIDEKIQ_SIZE
|
||||||
@@ -54,13 +54,13 @@ describe ::Redis::Config do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'checks for app redis config' do
|
it 'checks for app redis config' do
|
||||||
expect(described_class.app.keys).to match_array([:url, :password, :sentinels])
|
expect(described_class.app.keys).to match_array([:url, :password, :sentinels, :network_timeout, :reconnect_attempts])
|
||||||
expect(described_class.app[:url]).to eq("redis://#{redis_master_name}")
|
expect(described_class.app[:url]).to eq("redis://#{redis_master_name}")
|
||||||
expect(described_class.app[:sentinels]).to match_array(expected_sentinels)
|
expect(described_class.app[:sentinels]).to match_array(expected_sentinels)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'checks for sidekiq redis config' do
|
it 'checks for sidekiq redis config' do
|
||||||
expect(described_class.sidekiq.keys).to match_array([:url, :password, :sentinels, :size])
|
expect(described_class.sidekiq.keys).to match_array([:url, :password, :sentinels, :size, :network_timeout, :reconnect_attempts])
|
||||||
expect(described_class.sidekiq[:size]).to eq described_class::SIDEKIQ_SIZE
|
expect(described_class.sidekiq[:size]).to eq described_class::SIDEKIQ_SIZE
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user