mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 13:41:28 +00:00
corerouters --*-use-cache option can take an optional cache name
This commit is contained in:
@@ -652,6 +652,10 @@ void uwsgi_corerouter_loop(int id, void *data) {
|
||||
ucr->mapper = uwsgi_cr_map_use_void;
|
||||
|
||||
if (ucr->use_cache) {
|
||||
ucr->cache = uwsgi_cache_by_name(ucr->use_cache);
|
||||
if (!ucr->cache) {
|
||||
uwsgi_log("unable to find cache \"%s\"\n", ucr->use_cache);
|
||||
}
|
||||
ucr->mapper = uwsgi_cr_map_use_cache;
|
||||
}
|
||||
else if (ucr->pattern) {
|
||||
|
||||
@@ -197,7 +197,8 @@ struct uwsgi_corerouter {
|
||||
|
||||
struct rb_root *timeouts;
|
||||
|
||||
int use_cache;
|
||||
char *use_cache;
|
||||
struct uwsgi_cache *cache;
|
||||
int nevents;
|
||||
|
||||
int max_retries;
|
||||
|
||||
@@ -9,12 +9,14 @@ int uwsgi_cr_map_use_void(struct uwsgi_corerouter *ucr, struct corerouter_peer *
|
||||
}
|
||||
|
||||
int uwsgi_cr_map_use_cache(struct uwsgi_corerouter *ucr, struct corerouter_peer *peer) {
|
||||
peer->instance_address = uwsgi_cache_get(peer->key, peer->key_len, &peer->instance_address_len);
|
||||
uwsgi_rlock(ucr->cache->lock);
|
||||
peer->instance_address = uwsgi_cache_get2(ucr->cache, peer->key, peer->key_len, &peer->instance_address_len);
|
||||
char *cs_mod = uwsgi_str_contains(peer->instance_address, peer->instance_address_len, ',');
|
||||
if (cs_mod) {
|
||||
peer->modifier1 = uwsgi_str_num(cs_mod + 1, (peer->instance_address_len - (cs_mod - peer->instance_address)) - 1);
|
||||
peer->instance_address_len = (cs_mod - peer->instance_address);
|
||||
}
|
||||
uwsgi_rwunlock(ucr->cache->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ struct uwsgi_option fastrouter_options[] = {
|
||||
{"fastrouter-processes", required_argument, 0, "prefork the specified number of fastrouter processes", uwsgi_opt_set_int, &ufr.cr.processes, 0},
|
||||
{"fastrouter-workers", required_argument, 0, "prefork the specified number of fastrouter processes", uwsgi_opt_set_int, &ufr.cr.processes, 0},
|
||||
{"fastrouter-zerg", required_argument, 0, "attach the fastrouter to a zerg server", uwsgi_opt_corerouter_zerg, &ufr, 0},
|
||||
{"fastrouter-use-cache", no_argument, 0, "use uWSGI cache as hostname->server mapper for the fastrouter", uwsgi_opt_true, &ufr.cr.use_cache, 0},
|
||||
{"fastrouter-use-cache", optional_argument, 0, "use uWSGI cache as hostname->server mapper for the fastrouter", uwsgi_opt_set_str, &ufr.cr.use_cache, 0},
|
||||
|
||||
{"fastrouter-use-pattern", required_argument, 0, "use a pattern for fastrouter hostname->server mapping", uwsgi_opt_corerouter_use_pattern, &ufr, 0},
|
||||
{"fastrouter-use-base", required_argument, 0, "use a base dir for fastrouter hostname->server mapping", uwsgi_opt_corerouter_use_base, &ufr, 0},
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ struct uwsgi_option http_options[] = {
|
||||
{"http-zerg", required_argument, 0, "attach the http router to a zerg server", uwsgi_opt_corerouter_zerg, &uhttp, 0 },
|
||||
{"http-fallback", required_argument, 0, "fallback to the specified node in case of error", uwsgi_opt_add_string_list, &uhttp.cr.fallback, 0},
|
||||
{"http-modifier1", required_argument, 0, "set uwsgi protocol modifier1", uwsgi_opt_set_int, &uhttp.modifier1, 0},
|
||||
{"http-use-cache", no_argument, 0, "use uWSGI cache as key->value virtualhost mapper", uwsgi_opt_true, &uhttp.cr.use_cache, 0},
|
||||
{"http-use-cache", optional_argument, 0, "use uWSGI cache as key->value virtualhost mapper", uwsgi_opt_set_str, &uhttp.cr.use_cache, 0},
|
||||
{"http-use-pattern", required_argument, 0, "use the specified pattern for mapping requests to unix sockets", uwsgi_opt_corerouter_use_pattern, &uhttp, 0},
|
||||
{"http-use-base", required_argument, 0, "use the specified base for mapping requests to unix sockets", uwsgi_opt_corerouter_use_base, &uhttp, 0},
|
||||
{"http-use-cluster", no_argument, 0, "load balance to nodes subscribed to the cluster", uwsgi_opt_true, &uhttp.cr.use_cluster, 0},
|
||||
|
||||
@@ -31,7 +31,7 @@ struct uwsgi_option rawrouter_options[] = {
|
||||
{"rawrouter-processes", required_argument, 0, "prefork the specified number of rawrouter processes", uwsgi_opt_set_int, &urr.cr.processes, 0},
|
||||
{"rawrouter-workers", required_argument, 0, "prefork the specified number of rawrouter processes", uwsgi_opt_set_int, &urr.cr.processes, 0},
|
||||
{"rawrouter-zerg", required_argument, 0, "attach the rawrouter to a zerg server", uwsgi_opt_corerouter_zerg, &urr, 0},
|
||||
{"rawrouter-use-cache", no_argument, 0, "use uWSGI cache as hostname->server mapper for the rawrouter", uwsgi_opt_true, &urr.cr.use_cache, 0},
|
||||
{"rawrouter-use-cache", optional_argument, 0, "use uWSGI cache as hostname->server mapper for the rawrouter", uwsgi_opt_set_str, &urr.cr.use_cache, 0},
|
||||
|
||||
{"rawrouter-use-pattern", required_argument, 0, "use a pattern for rawrouter hostname->server mapping", uwsgi_opt_corerouter_use_pattern, &urr, 0},
|
||||
{"rawrouter-use-base", required_argument, 0, "use a base dir for rawrouter hostname->server mapping", uwsgi_opt_corerouter_use_base, &urr, 0},
|
||||
|
||||
Reference in New Issue
Block a user