fix: Abort redis retries only for esbuild
This commit is contained in:
parent
dc04fe9ed6
commit
807070282c
3 changed files with 27 additions and 14 deletions
|
|
@ -21,9 +21,9 @@ let {
|
|||
log,
|
||||
log_warn,
|
||||
log_error,
|
||||
bench_path
|
||||
bench_path,
|
||||
get_redis_subscriber
|
||||
} = require("./utils");
|
||||
let { get_redis_subscriber } = require("../node_utils");
|
||||
|
||||
let argv = yargs
|
||||
.usage("Usage: node esbuild [options]")
|
||||
|
|
|
|||
|
|
@ -110,6 +110,20 @@ function log(...args) {
|
|||
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 = {
|
||||
app_list,
|
||||
bench_path,
|
||||
|
|
@ -126,5 +140,6 @@ module.exports = {
|
|||
get_cli_arg,
|
||||
log,
|
||||
log_warn,
|
||||
log_error
|
||||
log_error,
|
||||
get_redis_subscriber
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,20 +38,18 @@ function get_conf() {
|
|||
return conf;
|
||||
}
|
||||
|
||||
function get_redis_subscriber(kind="redis_socketio") {
|
||||
function get_redis_subscriber(kind="redis_socketio", options=null) {
|
||||
const conf = get_conf();
|
||||
const host = conf[kind] || conf.redis_async_broker_port;
|
||||
|
||||
if (options) {
|
||||
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);
|
||||
},
|
||||
...options
|
||||
});
|
||||
}
|
||||
return redis.createClient(host);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
get_conf,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue