From 7aead375d8ffb2f8eafa3c699bd999ae99f99242 Mon Sep 17 00:00:00 2001 From: minvs1 Date: Tue, 21 Apr 2020 23:30:39 +0300 Subject: [PATCH] Allow to set custom retry parameters --- server/config.js | 10 ++++++++++ server/storage/redis.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/config.js b/server/config.js index 72b750ea..a6ad0bd2 100644 --- a/server/config.js +++ b/server/config.js @@ -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', diff --git a/server/storage/redis.js b/server/storage/redis.js index 645a8e7c..3118aadc 100644 --- a/server/storage/redis.js +++ b/server/storage/redis.js @@ -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; } });