added fastrouter-fallback-on-no-key

This commit is contained in:
Unbit
2014-06-24 09:48:27 +02:00
parent 5fb86e92f8
commit c532210d79
3 changed files with 10 additions and 3 deletions
-1
View File
@@ -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));
+1 -1
View File
@@ -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
+9 -1
View File
@@ -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;