fix: redis createClient call

This commit is contained in:
Faris Ansari 2021-05-18 15:48:18 +05:30
parent 792dd70730
commit c5c50c290e
2 changed files with 5 additions and 12 deletions

View file

@ -111,12 +111,12 @@ function log(...args) {
} }
function get_redis_subscriber(kind) { function get_redis_subscriber(kind) {
// get redis subscriber that aborts after 50 connection attempts // get redis subscriber that aborts after 10 connection attempts
let { get_redis_subscriber: get_redis } = require("../node_utils"); let { get_redis_subscriber: get_redis } = require("../node_utils");
return get_redis(kind, { return get_redis(kind, {
retry_strategy: function(options) { retry_strategy: function(options) {
// abort after 50 connection attempts // abort after 10 connection attempts
if (options.attempt > 50) { if (options.attempt > 10) {
return undefined; return undefined;
} }
return Math.min(options.attempt * 100, 2000); return Math.min(options.attempt * 100, 2000);

View file

@ -38,17 +38,10 @@ function get_conf() {
return conf; return conf;
} }
function get_redis_subscriber(kind="redis_socketio", options=null) { function get_redis_subscriber(kind="redis_socketio", options={}) {
const conf = get_conf(); const conf = get_conf();
const host = conf[kind] || conf.redis_async_broker_port; const host = conf[kind] || conf.redis_async_broker_port;
return redis.createClient({ url: host, ...options });
if (options) {
return redis.createClient({
host,
...options
});
}
return redis.createClient(host);
} }
module.exports = { module.exports = {