Use shared configurations in readwritesplit

By using a shared pointer instead of a plain object, we can replace the
router configuration without it affecting existing sessions. This is a
change that is required to enable runtime reconfiguration of
readwritesplit.
This commit is contained in:
Markus Mäkelä
2018-07-05 15:08:37 +03:00
parent 13763ace32
commit bd4be3a97b
7 changed files with 107 additions and 103 deletions

View File

@ -200,6 +200,8 @@ struct Config
bool optimistic_trx; /**< Enable optimistic transactions */
};
typedef std::tr1::shared_ptr<Config> SConfig;
/**
* The statistics for this router instance
*/
@ -226,11 +228,11 @@ class RWSplit: public mxs::Router<RWSplit, RWSplitSession>
RWSplit& operator=(const RWSplit&);
public:
RWSplit(SERVICE* service, const Config& config);
RWSplit(SERVICE* service, SConfig config);
~RWSplit();
SERVICE* service() const;
const Config& config() const;
SConfig config() const;
Stats& stats();
const Stats& stats() const;
int max_slave_count() const;
@ -298,7 +300,7 @@ public:
private:
SERVICE* m_service; /**< Service where the router belongs*/
Config m_config;
SConfig m_config;
Stats m_stats;
};