diff --git a/plugins/corerouter/corerouter.c b/plugins/corerouter/corerouter.c index 134c967a..1f869557 100644 --- a/plugins/corerouter/corerouter.c +++ b/plugins/corerouter/corerouter.c @@ -310,7 +310,6 @@ void corerouter_close_peer(struct uwsgi_corerouter *ucr, struct corerouter_peer } if (peer->failed) { - if (peer->soopt) { if (!ucr->quiet) uwsgi_log("[uwsgi-%s] unable to connect() to node \"%.*s\" (%d retries): %s\n", ucr->short_name, (int) peer->instance_address_len, peer->instance_address, peer->retries, strerror(peer->soopt)); diff --git a/plugins/corerouter/cr.h b/plugins/corerouter/cr.h index a67a1563..d8419c93 100644 --- a/plugins/corerouter/cr.h +++ b/plugins/corerouter/cr.h @@ -271,7 +271,7 @@ struct uwsgi_corerouter { char *resubscribe_bind; size_t buffer_size; - + int fallback_on_no_key; }; // a session is started when a client connect to the router diff --git a/plugins/fastrouter/fastrouter.c b/plugins/fastrouter/fastrouter.c index 47a52712..2c2537fb 100644 --- a/plugins/fastrouter/fastrouter.c +++ b/plugins/fastrouter/fastrouter.c @@ -55,6 +55,7 @@ static struct uwsgi_option fastrouter_options[] = { {"fastrouter-resubscribe-bind", required_argument, 0, "bind to the specified address when re-subscribing", uwsgi_opt_set_str, &ufr.cr.resubscribe_bind, 0}, {"fastrouter-buffer-size", required_argument, 0, "set internal buffer size (default: page size)", uwsgi_opt_set_64bit, &ufr.cr.buffer_size, 0}, + {"fastrouter-fallback-on-no-key", no_argument, 0, "move to fallback node even if a subscription key is not found", uwsgi_opt_true, &ufr.cr.fallback_on_no_key, 0}, {0, 0, 0, 0, 0, 0, 0}, }; @@ -226,8 +227,15 @@ static ssize_t fr_recv_uwsgi_vars(struct corerouter_peer *main_peer) { return -1; // check instance - if (new_peer->instance_address_len == 0) + if (new_peer->instance_address_len == 0) { + if (ufr.cr.fallback_on_no_key) { + new_peer->failed = 1; + new_peer->can_retry = 1; + corerouter_close_peer(&ufr.cr, new_peer); + return len; + } return -1; + } new_peer->can_retry = 1;