Do configuration outside of constructors
Configuration errors can be resolved before the instance is created. This avoids the unnecessary throws that were generated when an error occured. As the configuration is stored in the router, the router sessions can use a pointer to it instead of copying it locally. This should avoid some unnecessary copying if more complex configuration parameters are added.
This commit is contained in:
@ -20,30 +20,70 @@
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
|
||||
#include <limits>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <maxscale/pcre2.h>
|
||||
|
||||
using std::set;
|
||||
using std::string;
|
||||
|
||||
namespace schemarouter
|
||||
{
|
||||
/**
|
||||
* Configuration values
|
||||
*/
|
||||
typedef struct schemarouter_config_st
|
||||
struct Config
|
||||
{
|
||||
double refresh_min_interval; /**< Minimum required interval between refreshes of databases */
|
||||
bool refresh_databases; /**< Are databases refreshed when they are not found in the hashtable */
|
||||
bool debug; /**< Enable verbose debug messages to clients */
|
||||
} schemarouter_config_t;
|
||||
double refresh_min_interval; /**< Minimum required interval between
|
||||
* refreshes of databases */
|
||||
bool refresh_databases; /**< Are databases refreshed when
|
||||
* they are not found in the hashtable */
|
||||
bool debug; /**< Enable verbose debug messages to clients */
|
||||
pcre2_code* ignore_regex; /**< Regular expression used to ignore databases */
|
||||
pcre2_match_data* ignore_match_data; /**< Match data for @c ignore_regex */
|
||||
set<string> ignored_dbs; /**< Set of ignored databases */
|
||||
|
||||
Config():
|
||||
refresh_min_interval(0.0),
|
||||
refresh_databases(false),
|
||||
debug(false),
|
||||
ignore_regex(NULL),
|
||||
ignore_match_data(NULL)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The statistics for this router instance
|
||||
* Router statistics
|
||||
*/
|
||||
typedef struct
|
||||
struct Stats
|
||||
{
|
||||
int n_queries; /*< Number of queries forwarded */
|
||||
int n_sescmd; /*< Number of session commands */
|
||||
int longest_sescmd; /*< Longest chain of stored session commands */
|
||||
int n_hist_exceeded; /*< Number of sessions that exceeded session
|
||||
* command history limit */
|
||||
int sessions;
|
||||
int sessions; /*< Number of sessions */
|
||||
int shmap_cache_hit; /*< Shard map was found from the cache */
|
||||
int shmap_cache_miss; /*< No shard map found from the cache */
|
||||
double ses_longest; /*< Longest session */
|
||||
double ses_shortest; /*< Shortest session */
|
||||
double ses_average; /*< Average session length */
|
||||
int shmap_cache_hit; /*< Shard map was found from the cache */
|
||||
int shmap_cache_miss; /*< No shard map found from the cache */
|
||||
} ROUTER_STATS;
|
||||
|
||||
Stats():
|
||||
n_queries(0),
|
||||
n_sescmd(0),
|
||||
longest_sescmd(0),
|
||||
n_hist_exceeded(0),
|
||||
sessions(0),
|
||||
shmap_cache_hit(0),
|
||||
shmap_cache_miss(0),
|
||||
ses_longest(0.0),
|
||||
ses_shortest(std::numeric_limits<double>::max()),
|
||||
ses_average(0.0)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user