diff --git a/Documentation/Filters/CCRFilter.md b/Documentation/Filters/CCRFilter.md index 3028e1af3..a0b283369 100644 --- a/Documentation/Filters/CCRFilter.md +++ b/Documentation/Filters/CCRFilter.md @@ -57,8 +57,13 @@ The CCR filter has no mandatory parameters. ### `time` -The time window in seconds during which queries are routed to the master. The -default value for this parameter is 60 seconds. +The time window during which queries are routed to the master. The duration +can be specified as documented +[here](Getting-Started/Configuration-Guide.md#durations) +but the value will always be rounded to the nearest second. +If no explicit unit has been specified, the value is interpreted as seconds +in MaxScale 2.4. In subsequent versions a value without a unit may be rejected. +The default value for this parameter is 60 seconds. When a data modifying SQL statement is processed, a timer is set to the value of _time_. Once the timer has elapsed, all statements are routed normally. If a new diff --git a/server/modules/filter/ccrfilter/ccrfilter.cc b/server/modules/filter/ccrfilter/ccrfilter.cc index 4666f3f66..6b9fcfba0 100644 --- a/server/modules/filter/ccrfilter/ccrfilter.cc +++ b/server/modules/filter/ccrfilter/ccrfilter.cc @@ -90,7 +90,9 @@ public: if (new_instance) { new_instance->m_count = params->get_integer("count"); - new_instance->m_time = params->get_integer("time"); + new_instance->m_time = params->get_duration("time", mxs::config::INTERPRET_AS_SECONDS).count(); + // The window is in seconds. + new_instance->m_time = std::lround(new_instance->m_time / 1000.0); new_instance->m_match = params->get_string(PARAM_MATCH); new_instance->m_nomatch = params->get_string(PARAM_IGNORE); @@ -345,11 +347,11 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() NULL, /* Thread init. */ NULL, /* Thread finish. */ { - {"count", MXS_MODULE_PARAM_COUNT, "0" }, - {"time", MXS_MODULE_PARAM_COUNT, "60" }, + {"count", MXS_MODULE_PARAM_COUNT, "0"}, + {"time", MXS_MODULE_PARAM_DURATION, "60s"}, {PARAM_MATCH, MXS_MODULE_PARAM_REGEX}, {PARAM_IGNORE, MXS_MODULE_PARAM_REGEX}, - {"options", MXS_MODULE_PARAM_ENUM, "ignorecase", MXS_MODULE_OPT_NONE, option_values}, + {"options", MXS_MODULE_PARAM_ENUM, "ignorecase", MXS_MODULE_OPT_NONE, option_values}, {MXS_END_MODULE_PARAMS} } };