Merge pull request #1465 from minvs1/redis-retry-configs

Allow to set custom retry parameters
This commit is contained in:
Danny Coates 2020-07-09 19:17:28 -07:00 committed by GitHub
commit 3195ee7d16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -69,6 +69,16 @@ const conf = convict({
default: false,
env: 'REDIS_EVENT_EXPIRE'
},
redis_retry_time: {
format: Number,
default: 10000,
env: 'REDIS_RETRY_TIME'
},
redis_retry_delay: {
format: Number,
default: 500,
env: 'REDIS_RETRY_DELAY'
},
listen_address: {
format: 'ipaddress',
default: '0.0.0.0',

View File

@ -11,12 +11,12 @@ module.exports = function(config) {
const client = redis.createClient({
host: config.redis_host,
retry_strategy: options => {
if (options.total_retry_time > 10000) {
if (options.total_retry_time > config.redis_retry_time) {
client.emit('error', 'Retry time exhausted');
return new Error('Retry time exhausted');
}
return 500;
return config.redis_retry_delay;
}
});