MXS-2556 Make config::Configuration aware of its object

The name of the object (i.e. the section name from the configuration
file), is now stored in the configuration object for that object.

That way, more contextual and hence morfe user friendly errors and
warnings can be generated.
This commit is contained in:
Johan Wikman
2019-06-11 11:05:15 +03:00
parent df5377f135
commit 04fdaf1fdb
11 changed files with 37 additions and 20 deletions

View File

@ -65,8 +65,8 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
return &info;
}
SmartRouter::Config::Config()
: config::Configuration(&smartquery::specification)
SmartRouter::Config::Config(const std::string& name)
: config::Configuration(name, &smartquery::specification)
, m_master(this, &smartquery::master)
{
}
@ -100,10 +100,10 @@ bool SmartRouter::Config::post_configure(const MXS_CONFIG_PARAMETER& params)
{
if (strcmp(pServer->address, "127.0.0.1") == 0 || strcmp(pServer->address, "localhost"))
{
MXS_WARNING("The server %s, used by the smartrouter, is currently accessed "
MXS_WARNING("The server %s, used by the smartrouter %s, is currently accessed "
"using a TCP/IP socket (%s:%d). For better performance, a Unix "
"domain socket should be used. See the 'socket' argument.",
pServer->name(), pServer->address, pServer->port);
pServer->name(), name().c_str(), pServer->address, pServer->port);
}
}
}
@ -124,8 +124,9 @@ bool SmartRouter::Config::post_configure(const MXS_CONFIG_PARAMETER& params)
s += server->name();
}
MXS_ERROR("The master server %s, is not one of the servers (%s) of the service.",
m_master.get()->name(), s.c_str());
MXS_ERROR("The master server %s of the smartrouter %s, is not one of the "
"servers (%s) of the service.",
m_master.get()->name(), name().c_str(), s.c_str());
}
return rv;
@ -149,6 +150,7 @@ SERVICE* SmartRouter::service() const
SmartRouter::SmartRouter(SERVICE* service)
: mxs::Router<SmartRouter, SmartRouterSession>(service)
, m_config(service->name())
{
}

View File

@ -32,7 +32,7 @@ public:
class Config : public config::Configuration
{
public:
Config();
Config(const std::string& name);
Config(const Config&) = delete;
Config& operator=(const Config&) = delete;