mirror of https://github.com/yandex/odyssey.git
odissey: add config file/scheme print
This commit is contained in:
parent
6b95df733e
commit
59a737b9f9
|
@ -1,3 +1,6 @@
|
||||||
|
|
||||||
|
# odissey config file.
|
||||||
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
odissey {
|
odissey {
|
||||||
|
@ -38,7 +41,6 @@ odissey {
|
||||||
|
|
||||||
routing {
|
routing {
|
||||||
mode "forward" # round-robin
|
mode "forward" # round-robin
|
||||||
|
|
||||||
"bardb" {
|
"bardb" {
|
||||||
pool_min 0
|
pool_min 0
|
||||||
pool_max 100
|
pool_max 100
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include "od_macro.h"
|
#include "od_macro.h"
|
||||||
#include "od_list.h"
|
#include "od_list.h"
|
||||||
#include "od_scheme.h"
|
|
||||||
#include "od_lex.h"
|
#include "od_lex.h"
|
||||||
|
|
||||||
void od_lexinit(odlex_t *l, odkeyword_t *list, char *buf, int size)
|
void od_lexinit(odlex_t *l, odkeyword_t *list, char *buf, int size)
|
||||||
|
|
|
@ -10,16 +10,37 @@
|
||||||
|
|
||||||
#include "od_macro.h"
|
#include "od_macro.h"
|
||||||
#include "od_list.h"
|
#include "od_list.h"
|
||||||
|
#include "od_log.h"
|
||||||
#include "od_scheme.h"
|
#include "od_scheme.h"
|
||||||
|
|
||||||
void od_schemeinit(odscheme_t *scheme)
|
void od_schemeinit(odscheme_t *scheme)
|
||||||
{
|
{
|
||||||
(void)scheme;
|
scheme->config_file = NULL;
|
||||||
|
scheme->daemonize = 0;
|
||||||
|
scheme->log_file = NULL;
|
||||||
|
scheme->pid_file = NULL;
|
||||||
|
scheme->host = "127.0.0.1";
|
||||||
|
scheme->port = 6432;
|
||||||
|
scheme->workers = 1;
|
||||||
|
scheme->client_max = 100;
|
||||||
|
scheme->routing = "forward";
|
||||||
|
od_listinit(&scheme->servers);
|
||||||
|
od_listinit(&scheme->routing_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
void od_schemefree(odscheme_t *scheme)
|
void od_schemefree(odscheme_t *scheme)
|
||||||
{
|
{
|
||||||
(void)scheme;
|
odlist_t *i, *n;
|
||||||
|
od_listforeach_safe(&scheme->servers, i, n) {
|
||||||
|
odscheme_server_t *server;
|
||||||
|
server = od_container_of(i, odscheme_server_t, link);
|
||||||
|
free(server);
|
||||||
|
}
|
||||||
|
od_listforeach_safe(&scheme->servers, i, n) {
|
||||||
|
odscheme_route_t *route;
|
||||||
|
route = od_container_of(i, odscheme_route_t, link);
|
||||||
|
free(route);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
odscheme_server_t*
|
odscheme_server_t*
|
||||||
|
@ -47,3 +68,46 @@ od_scheme_addroute(odscheme_t *scheme)
|
||||||
od_listappend(&scheme->routing_table, &r->link);
|
od_listappend(&scheme->routing_table, &r->link);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void od_schemeprint(odscheme_t *scheme, odlog_t *log)
|
||||||
|
{
|
||||||
|
if (scheme->config_file)
|
||||||
|
od_log(log, "using configuration file '%s'",
|
||||||
|
scheme->config_file);
|
||||||
|
else
|
||||||
|
od_log(log, "using default settings");
|
||||||
|
if (scheme->log_file)
|
||||||
|
od_log(log, "log_file '%s'", scheme->log_file);
|
||||||
|
if (scheme->pid_file)
|
||||||
|
od_log(log, "pid_file '%s'", scheme->pid_file);
|
||||||
|
if (scheme->daemonize)
|
||||||
|
od_log(log, "daemonize %s",
|
||||||
|
scheme->daemonize ? "yes" : "no");
|
||||||
|
od_log(log, "pooling '%s'", scheme->pooling);
|
||||||
|
od_log(log, "");
|
||||||
|
od_log(log, "servers");
|
||||||
|
odlist_t *i;
|
||||||
|
od_listforeach(&scheme->servers, i) {
|
||||||
|
odscheme_server_t *server;
|
||||||
|
server = od_container_of(i, odscheme_server_t, link);
|
||||||
|
od_log(log, " <%s> %s",
|
||||||
|
server->name ? server->name : "",
|
||||||
|
server->is_default ? "default" : "");
|
||||||
|
od_log(log, " host '%s'", server->host);
|
||||||
|
od_log(log, " port '%d'", server->port);
|
||||||
|
|
||||||
|
}
|
||||||
|
od_log(log, "routing");
|
||||||
|
od_log(log, " mode '%s'", scheme->routing);
|
||||||
|
od_listforeach(&scheme->routing_table, i) {
|
||||||
|
odscheme_route_t *route;
|
||||||
|
route = od_container_of(i, odscheme_route_t, link);
|
||||||
|
od_log(log, " >> %s", route->database);
|
||||||
|
if (route->user)
|
||||||
|
od_log(log, " user '%s'", route->user);
|
||||||
|
if (route->password)
|
||||||
|
od_log(log, " password '****'");
|
||||||
|
od_log(log, " pool_min %d", route->pool_min);
|
||||||
|
od_log(log, " pool_max %d", route->pool_max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -52,8 +52,9 @@ void od_schemefree(odscheme_t*);
|
||||||
|
|
||||||
odscheme_server_t*
|
odscheme_server_t*
|
||||||
od_scheme_addserver(odscheme_t*);
|
od_scheme_addserver(odscheme_t*);
|
||||||
|
|
||||||
odscheme_route_t*
|
odscheme_route_t*
|
||||||
od_scheme_addroute(odscheme_t*);
|
od_scheme_addroute(odscheme_t*);
|
||||||
|
|
||||||
|
void od_schemeprint(odscheme_t*, odlog_t*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue