MXS-2329 Use durations in schema router

This commit is contained in:
Johan Wikman 2019-04-29 13:48:37 +03:00
parent ea243fd8ba
commit aa3057695b
3 changed files with 18 additions and 10 deletions

View File

@ -200,6 +200,13 @@ change the database i.e. `USE ...` queries.
The minimum interval between database map refreshes in seconds.
The interval is specified as documented
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
versions a value without a unit may be rejected. Note that since the granularity
of the intervaltimeout is seconds, a timeout specified in milliseconds will be rejected,
even if the duration is longer than a second.
## Limitations
1. Cross-database queries (e.g. `SELECT column FROM database1.table UNION select column

View File

@ -19,7 +19,7 @@ namespace schemarouter
{
Config::Config(MXS_CONFIG_PARAMETER* conf)
: refresh_min_interval(conf->get_integer("refresh_interval"))
: refresh_min_interval(conf->get_duration<std::chrono::seconds>("refresh_interval").count())
, refresh_databases(conf->get_bool("refresh_databases"))
, debug(conf->get_bool("debug"))
, ignore_regex(conf->get_compiled_regex("ignore_databases_regex", 0, NULL).release())

View File

@ -34,7 +34,7 @@ using std::string;
namespace schemarouter
{
#define DEFAULT_REFRESH_INTERVAL "300"
#define DEFAULT_REFRESH_INTERVAL "300s"
/**
* @file schemarouter.c The entry points for the simple sharding router module.
@ -294,14 +294,15 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{"ignore_databases", MXS_MODULE_PARAM_STRING },
{"ignore_databases_regex", MXS_MODULE_PARAM_STRING },
{"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "0"},
{"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false"},
{"refresh_databases", MXS_MODULE_PARAM_BOOL, "true"},
{"refresh_interval", MXS_MODULE_PARAM_COUNT, DEFAULT_REFRESH_INTERVAL},
{"debug", MXS_MODULE_PARAM_BOOL, "false"},
{"preferred_server", MXS_MODULE_PARAM_SERVER },
{"ignore_databases", MXS_MODULE_PARAM_STRING },
{"ignore_databases_regex", MXS_MODULE_PARAM_STRING },
{"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "0"},
{"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false"},
{"refresh_databases", MXS_MODULE_PARAM_BOOL, "true"},
{"refresh_interval", MXS_MODULE_PARAM_DURATION, DEFAULT_REFRESH_INTERVAL,
MXS_MODULE_OPT_DURATION_S },
{"debug", MXS_MODULE_PARAM_BOOL, "false"},
{"preferred_server", MXS_MODULE_PARAM_SERVER },
{MXS_END_MODULE_PARAMS}
}
};