@@ -21,9 +21,9 @@ let { | |||||
log, | log, | ||||
log_warn, | log_warn, | ||||
log_error, | log_error, | ||||
bench_path | |||||
bench_path, | |||||
get_redis_subscriber | |||||
} = require("./utils"); | } = require("./utils"); | ||||
let { get_redis_subscriber } = require("../node_utils"); | |||||
let argv = yargs | let argv = yargs | ||||
.usage("Usage: node esbuild [options]") | .usage("Usage: node esbuild [options]") | ||||
@@ -110,6 +110,20 @@ function log(...args) { | |||||
console.log(...args); // eslint-disable-line no-console | console.log(...args); // eslint-disable-line no-console | ||||
} | } | ||||
function get_redis_subscriber(kind) { | |||||
// get redis subscriber that aborts after 50 connection attempts | |||||
let { get_redis_subscriber: get_redis } = require("../node_utils"); | |||||
return get_redis(kind, { | |||||
retry_strategy: function(options) { | |||||
// abort after 50 connection attempts | |||||
if (options.attempt > 50) { | |||||
return undefined; | |||||
} | |||||
return Math.min(options.attempt * 100, 2000); | |||||
} | |||||
}); | |||||
} | |||||
module.exports = { | module.exports = { | ||||
app_list, | app_list, | ||||
bench_path, | bench_path, | ||||
@@ -126,5 +140,6 @@ module.exports = { | |||||
get_cli_arg, | get_cli_arg, | ||||
log, | log, | ||||
log_warn, | log_warn, | ||||
log_error | |||||
log_error, | |||||
get_redis_subscriber | |||||
}; | }; |
@@ -38,19 +38,17 @@ function get_conf() { | |||||
return conf; | return conf; | ||||
} | } | ||||
function get_redis_subscriber(kind="redis_socketio") { | |||||
function get_redis_subscriber(kind="redis_socketio", options=null) { | |||||
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({ | |||||
host, | |||||
retry_strategy: function(options) { | |||||
// abort after 5 connection attempts | |||||
if (options.attempt > 5) { | |||||
return undefined; | |||||
} | |||||
return Math.min(options.attempt * 100, 2000); | |||||
}, | |||||
}); | |||||
if (options) { | |||||
return redis.createClient({ | |||||
host, | |||||
...options | |||||
}); | |||||
} | |||||
return redis.createClient(host); | |||||
} | } | ||||
module.exports = { | module.exports = { | ||||