From 1fb8cde5d8c439b303c6e1f7a875bc1b04bf4196 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Mon, 3 Apr 2017 11:24:43 +0300 Subject: [PATCH] NamedServerFilter: Add HINT_ROUTE_TO_ALL support This was already supported by HintRouter. The tag for the MaxScale config file is "->all". Also add note to Documentation and reformat it a bit. --- Documentation/Filters/Named-Server-Filter.md | 12 ++++++++---- include/maxscale/hint.h | 4 ++-- .../filter/namedserverfilter/namedserverfilter.cc | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Documentation/Filters/Named-Server-Filter.md b/Documentation/Filters/Named-Server-Filter.md index 0a8fe1c6d..068182406 100644 --- a/Documentation/Filters/Named-Server-Filter.md +++ b/Documentation/Filters/Named-Server-Filter.md @@ -66,10 +66,14 @@ match01=^SELECT This is the hint which will be attached to the queries matching the regex. If a compatible router is used in the service the query will be routed accordingly. -The target can be a server name, a list of server names (comma-separated), -`->master` or `->slave`. The server names add the names as hints (one name per -hint). `->master` adds a *route-to-master*- hint and `->slave` adds a -*route-to-slave*-hint. +The target can be one of the following: + + * a server name (adds a `HINT_ROUTE_TO_NAMED_SERVER` hint) + * a list of server names, comma-separated (adds several + `HINT_ROUTE_TO_NAMED_SERVER` hints) + * `->master` (adds a `HINT_ROUTE_TO_MASTER` hint) + * `->slave` (adds a `HINT_ROUTE_TO_SLAVE` hint) + * `->all` (adds a `HINT_ROUTE_TO_ALL` hint) ``` target01=MyServer2 diff --git a/include/maxscale/hint.h b/include/maxscale/hint.h index d91c3523a..8a331020a 100644 --- a/include/maxscale/hint.h +++ b/include/maxscale/hint.h @@ -29,8 +29,8 @@ typedef enum HINT_ROUTE_TO_MASTER = 1, HINT_ROUTE_TO_SLAVE, HINT_ROUTE_TO_NAMED_SERVER, - HINT_ROUTE_TO_UPTODATE_SERVER, - HINT_ROUTE_TO_ALL, /*< not implemented yet */ + HINT_ROUTE_TO_UPTODATE_SERVER, /*< not supported by RWSplit and HintRouter */ + HINT_ROUTE_TO_ALL, /*< not supported by RWSplit, supported by HintRouter */ HINT_PARAMETER } HINT_TYPE; diff --git a/server/modules/filter/namedserverfilter/namedserverfilter.cc b/server/modules/filter/namedserverfilter/namedserverfilter.cc index 4a748cc92..53f8a49cc 100644 --- a/server/modules/filter/namedserverfilter/namedserverfilter.cc +++ b/server/modules/filter/namedserverfilter/namedserverfilter.cc @@ -432,6 +432,11 @@ int RegexToServers::add_servers(string server_names, bool legacy_mode) m_targets.push_back(names_arr[0]); m_htype = HINT_ROUTE_TO_SLAVE; } + else if (strcmp(names_arr[0], "->all") == 0) + { + m_targets.push_back(names_arr[0]); + m_htype = HINT_ROUTE_TO_ALL; + } else { error = true;