From af6e010ba19302b36a0661c5ebc3c5eafe21685c Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 10 Jul 2015 13:51:32 +0300 Subject: [PATCH 1/2] Added missing namedserverfilter documentation. --- Documentation/Filters/Named-Server-Filter.md | 92 ++++++++++++++++++++ server/modules/filter/namedserverfilter.c | 2 +- 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 Documentation/Filters/Named-Server-Filter.md diff --git a/Documentation/Filters/Named-Server-Filter.md b/Documentation/Filters/Named-Server-Filter.md new file mode 100644 index 000000000..3e41092de --- /dev/null +++ b/Documentation/Filters/Named-Server-Filter.md @@ -0,0 +1,92 @@ +Named Server Filter + +# Overview + +The **namedserverfilter** is a filter module for MaxScale which is able to route queries to servers based on regular expression matches. + +# Configuration + +The configuration block for the Named Server filter requires the minimal filter options in it’s section within the maxscale.cnf file, stored in /etc/maxscale.cnf. + +``` +[NamedServerFilter] +type=filter +module=namedserverfilter +match=some string +server=server2 + +[MyService] +type=service +router=readwritesplit +servers=server1,server2 +user=myuser +passwd=mypasswd +filters=NamedServerFilter +``` + +## Filter Options + +The named server filter accepts the options ignorecase or case. These define if the pattern text should take the case of the string it is matching against into consideration or not. + +## Filter Parameters + +The named server filter requires two mandatory parameters to be defined. + +### `match` + +A parameter that can be used to match text in the SQL statement which should be replaced. + +``` +match=TYPE[ ]*= +``` + +If the filter option ignorecase is used all regular expressions are evaluated with the option to ignore the case of the text, therefore a match option of select will match both type, TYPE and any form of the word with upper or lowercase characters. + +### `server` + +This is the server where matching queries will be router. The server should be in use by the service which uses this filter. + +``` +server=server2 +``` + +### `source` + +The optional source parameter defines an address that is used to match against the address from which the client connection to MaxScale originates. Only sessions that originate from this address will have the match and replacement applied to them. + +``` +source=127.0.0.1 +``` + +### `user` + +The optional user parameter defines a user name that is used to match against the user from which the client connection to MaxScale originates. Only sessions that are connected using this username will have the match and replacement applied to them. + +``` +user=john +``` + +## Examples + +### Example 1 - Route queries targeting a specific table to a server + +This will route all queries matching the regular expression ` *from *users` to the server named *server2*. The filter will ignore character case in queries. + +A query like `SELECT * FROM users` would be routed to server2 where as a query like `SELECT * FROM accounts` would be routed according to the normal rules of the router. + +``` +[NamedServerFilter] +type=filter +module=namedserverfilter +match= *from *users +options=ignorecase +server=server2 + +[MyService] +type=service +router=readwritesplit +servers=server1,server2 +user=myuser +passwd=mypasswd +filters=NamedServerFilter +``` diff --git a/server/modules/filter/namedserverfilter.c b/server/modules/filter/namedserverfilter.c index b7a5b91c1..822b5eaf2 100644 --- a/server/modules/filter/namedserverfilter.c +++ b/server/modules/filter/namedserverfilter.c @@ -35,7 +35,7 @@ extern __thread log_info_t tls_log_info; * that routes to a named server if a regular expression match is found. * @verbatim * - * A simple regular expression query rewrite filter. + * A simple regular expression based query routing filter. * Two parameters should be defined in the filter configuration * match= * server= From 8fb2cf7064a3159fd4ef9b1ed7b88c17650b546c Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 10 Jul 2015 13:52:42 +0300 Subject: [PATCH 2/2] Added missing link --- Documentation/Documentation-Contents.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/Documentation-Contents.md b/Documentation/Documentation-Contents.md index a2f453a7b..fd13f3bf1 100644 --- a/Documentation/Documentation-Contents.md +++ b/Documentation/Documentation-Contents.md @@ -62,6 +62,7 @@ Here are detailed documents about the filters MaxScale offers. They contain conf - [Top N Filter](Filters/Top-N-Filter.md) - [Database Firewall Filter](Filters/Database-Firewall-Filter.md) - [RabbitMQ Filter](Filters/RabbitMQ-Filter.md) + - [Named Server Filter](Filters/Named-Server-Filter.md) ## Monitors - [MySQL Monitor](Monitors/MySQL-Monitor.md)