Use module parameters in schemarouter

The schemarouter now accepts all router_options values as parameters.

Also fixed a mistake in the documentation where the router options section
was listed twice.
This commit is contained in:
Markus Mäkelä 2017-01-05 15:06:04 +02:00
parent 34a8694b34
commit e75cdb2ceb
2 changed files with 36 additions and 10 deletions

View File

@ -21,7 +21,6 @@ router=schemarouter
servers=server1,server2
user=myuser
passwd=mypwd
auth_all_servers=1
```
The module generates the list of databases based on the servers parameter using the connecting client's credentials. The user and passwd parameters define the credentials that are used to fetch the authentication data from the database servers. The credentials used only require the same grants as mentioned in the configuration documentation.
@ -42,11 +41,7 @@ GRANT SELECT,USAGE ON shard.* TO 'john'@'%';
This would in effect allow the user 'john' to only see the database 'shard' on this server. Take notice that these grants are matched against MariaDB MaxScale's hostname instead of the client's hostname. Only user authentication uses the client's hostname and all other grants use MariaDB MaxScale's hostname.
## Router options
The following options are options for the `router_options` parameter of the
service. Multiple router options are given as a comma separated list of key
value pairs.
## Router Parameters
### `ignore_databases`
@ -56,7 +51,26 @@ List of databases to ignore when checking for duplicate databases.
Regular expression that is matched against database names when checking for duplicate databases.
## Router options
**Note:** As of version 2.1 of MaxScale, all of the router options can also be
defined as parameters. The values defined in _router_options_ will have priority
over the parameters.
```
[Shard Router]
type=service
router=schemarouter
servers=server1,server2
user=myuser
passwd=mypwd
refresh_databases=true
refresh_interval=60
```
## Router Options
The following options are options for the `router_options` parameter of the
service. Multiple router options are given as a comma separated list of key
value pairs.
### `max_sescmd_history`

View File

@ -32,7 +32,7 @@
#include <maxscale/poll.h>
#include <pcre.h>
#define DEFAULT_REFRESH_INTERVAL 30.0
#define DEFAULT_REFRESH_INTERVAL "300"
/** Size of the hashtable used to store ignored databases */
#define SCHEMAROUTER_HASHSIZE 100
@ -624,6 +624,13 @@ 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"},
{MXS_END_MODULE_PARAMS}
}
};
@ -677,8 +684,6 @@ static ROUTER* createInstance(SERVICE *service, char **options)
router->service = service;
router->schemarouter_config.max_sescmd_hist = 0;
router->schemarouter_config.last_refresh = time(NULL);
router->schemarouter_config.refresh_databases = false;
router->schemarouter_config.refresh_min_interval = DEFAULT_REFRESH_INTERVAL;
router->stats.longest_sescmd = 0;
router->stats.n_hist_exceeded = 0;
router->stats.n_queries = 0;
@ -688,6 +693,13 @@ static ROUTER* createInstance(SERVICE *service, char **options)
spinlock_init(&router->lock);
conf = service->svc_config_param;
router->schemarouter_config.refresh_databases = config_get_bool(conf, "refresh_databases");
router->schemarouter_config.refresh_min_interval = config_get_integer(conf, "refresh_interval");
router->schemarouter_config.max_sescmd_hist = config_get_integer(conf, "max_sescmd_history");
router->schemarouter_config.disable_sescmd_hist = config_get_bool(conf, "disable_sescmd_history");
router->schemarouter_config.debug = config_get_bool(conf, "debug");
if ((config_get_param(conf, "auth_all_servers")) == NULL)
{
MXS_NOTICE("Schemarouter: Authentication data is fetched from all servers. To disable this "