mirror of https://github.com/yandex/odyssey.git
odissey: configure and send timezone to a client
This commit is contained in:
parent
3aff6627a1
commit
70ac93378f
|
@ -54,6 +54,9 @@ database "console" {
|
|||
authentication "none"
|
||||
pool "session"
|
||||
storage "local"
|
||||
client_encoding "UTF8"
|
||||
datestyle "ISO"
|
||||
timezone "UTC"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +81,8 @@ database default
|
|||
pool_rollback yes
|
||||
|
||||
#client_max 100
|
||||
#client_encoding "UTF-8"
|
||||
#datestyle "ISO"
|
||||
client_encoding "UTF8"
|
||||
datestyle "ISO"
|
||||
timezone "UTC"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,9 @@ database "console" {
|
|||
authentication "none"
|
||||
pool "session"
|
||||
storage "local"
|
||||
client_encoding "UTF8"
|
||||
datestyle "ISO"
|
||||
timezone "UTC"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +81,8 @@ database default
|
|||
pool_rollback yes
|
||||
|
||||
#client_max 100
|
||||
#client_encoding "UTF-8"
|
||||
#datestyle "ISO"
|
||||
client_encoding "UTF8"
|
||||
datestyle "ISO"
|
||||
timezone "UTC"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ enum
|
|||
OD_LCLIENT_MAX,
|
||||
OD_LCLIENT_ENCODING,
|
||||
OD_LDATESTYLE,
|
||||
OD_LTIMEZONE,
|
||||
OD_LTLS,
|
||||
OD_LTLS_CA_FILE,
|
||||
OD_LTLS_KEY_FILE,
|
||||
|
@ -133,6 +134,7 @@ static od_keyword_t od_config_keywords[] =
|
|||
od_keyword("client_max", OD_LCLIENT_MAX),
|
||||
od_keyword("client_encoding", OD_LCLIENT_ENCODING),
|
||||
od_keyword("datestyle", OD_LDATESTYLE),
|
||||
od_keyword("timezone", OD_LTIMEZONE),
|
||||
od_keyword("tls", OD_LTLS),
|
||||
od_keyword("tls_ca_file", OD_LTLS_CA_FILE),
|
||||
od_keyword("tls_key_file", OD_LTLS_KEY_FILE),
|
||||
|
@ -625,11 +627,19 @@ od_config_parse_route(od_config_t *config, char *db_name, int db_name_len,
|
|||
case OD_LCLIENT_ENCODING:
|
||||
if (! od_config_next_string(config, &route->client_encoding))
|
||||
return -1;
|
||||
route->client_encoding_len = strlen(route->client_encoding);
|
||||
continue;
|
||||
/* datestyle */
|
||||
case OD_LDATESTYLE:
|
||||
if (! od_config_next_string(config, &route->datestyle))
|
||||
return -1;
|
||||
route->datestyle_len = strlen(route->datestyle);
|
||||
continue;
|
||||
/* timezone */
|
||||
case OD_LTIMEZONE:
|
||||
if (! od_config_next_string(config, &route->timezone))
|
||||
return -1;
|
||||
route->timezone_len = strlen(route->timezone);
|
||||
continue;
|
||||
/* pool */
|
||||
case OD_LPOOL:
|
||||
|
|
|
@ -203,18 +203,30 @@ od_frontend_setup(od_client_t *client)
|
|||
client->key.key);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
/* set default client_encoding */
|
||||
/* client_encoding */
|
||||
if (client->scheme->client_encoding) {
|
||||
rc = shapito_be_write_parameter_status(stream, "client_encoding", 16,
|
||||
client->scheme->client_encoding,
|
||||
client->scheme->client_encoding_len + 1);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
/* set default datestyle */
|
||||
}
|
||||
/* datestyle */
|
||||
if (client->scheme->datestyle) {
|
||||
rc = shapito_be_write_parameter_status(stream, "datestyle", 10,
|
||||
client->scheme->datestyle,
|
||||
client->scheme->datestyle_len + 1);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
}
|
||||
/* timezone */
|
||||
if (client->scheme->timezone) {
|
||||
rc = shapito_be_write_parameter_status(stream, "timezone", 9,
|
||||
client->scheme->timezone,
|
||||
client->scheme->timezone_len + 1);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
}
|
||||
rc = od_write(client->io, stream);
|
||||
if (rc == -1) {
|
||||
od_error_client(&instance->logger, &client->id, "setup",
|
||||
|
|
|
@ -336,6 +336,8 @@ void od_schemeroute_free(od_schemeroute_t *route)
|
|||
free(route->client_encoding);
|
||||
if (route->datestyle)
|
||||
free(route->datestyle);
|
||||
if (route->timezone)
|
||||
free(route->timezone);
|
||||
if (route->storage)
|
||||
od_schemestorage_free(route->storage);
|
||||
if (route->storage_name)
|
||||
|
@ -484,6 +486,15 @@ int od_schemeroute_compare(od_schemeroute_t *a, od_schemeroute_t *b)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* timezone */
|
||||
if (a->timezone && b->timezone) {
|
||||
if (strcmp(a->timezone, b->timezone) != 0)
|
||||
return 0;
|
||||
} else
|
||||
if (a->timezone || b->timezone) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* storage */
|
||||
if (strcmp(a->storage_name, b->storage_name) != 0)
|
||||
return 0;
|
||||
|
@ -742,22 +753,6 @@ int od_scheme_validate(od_scheme_t *scheme, od_logger_t *logger)
|
|||
route->db_name, route->user_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* client_encoding */
|
||||
if (route->client_encoding == NULL) {
|
||||
route->client_encoding = strdup("UTF-8");
|
||||
if (route->client_encoding == NULL)
|
||||
return -1;
|
||||
route->client_encoding_len = strlen(route->client_encoding);
|
||||
}
|
||||
|
||||
/* datestyle */
|
||||
if (route->datestyle == NULL) {
|
||||
route->datestyle = strdup("ISO");
|
||||
if (route->datestyle == NULL)
|
||||
return -1;
|
||||
route->datestyle_len = strlen(route->datestyle);
|
||||
}
|
||||
}
|
||||
|
||||
if (! route_default_default) {
|
||||
|
@ -863,8 +858,12 @@ log_routes:;
|
|||
route->pool_discard ? "yes" : "no");
|
||||
if (route->client_max_set)
|
||||
od_log(logger, " client_max %d", route->client_max);
|
||||
if (route->client_encoding)
|
||||
od_log(logger, " client_encoding %s", route->client_encoding);
|
||||
if (route->datestyle)
|
||||
od_log(logger, " datestyle %s", route->datestyle);
|
||||
if (route->timezone)
|
||||
od_log(logger, " timezone %s", route->timezone);
|
||||
od_log(logger, " storage %s", route->storage_name);
|
||||
od_log(logger, " type %s", route->storage->type);
|
||||
if (route->storage->host)
|
||||
|
|
|
@ -95,6 +95,8 @@ struct od_schemeroute
|
|||
int client_encoding_len;
|
||||
char *datestyle;
|
||||
int datestyle_len;
|
||||
char *timezone;
|
||||
int timezone_len;
|
||||
/* pool */
|
||||
od_pooling_t pool;
|
||||
char *pool_sz;
|
||||
|
|
Loading…
Reference in New Issue