Add name and uri helpers to Backend
Providing helper functions for the commonly used parts of the server makes code easier to read. It also removes any possibility for formatting problems by moving the URI and name string handling inside the Backend class.
This commit is contained in:
@ -12,6 +12,9 @@
|
||||
*/
|
||||
|
||||
#include <maxscale/backend.hh>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <maxscale/protocol/mysql.h>
|
||||
#include <maxscale/debug.h>
|
||||
|
||||
@ -23,6 +26,9 @@ Backend::Backend(SERVER_REF *ref):
|
||||
m_dcb(NULL),
|
||||
m_state(0)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "[" << server()->name << "]:" << server()->port;
|
||||
m_uri = ss.str();
|
||||
}
|
||||
|
||||
Backend::~Backend()
|
||||
@ -298,3 +304,13 @@ bool Backend::has_failed() const
|
||||
{
|
||||
return m_state & FATAL_FAILURE;
|
||||
}
|
||||
|
||||
const char* Backend::name() const
|
||||
{
|
||||
return m_backend->server->unique_name;
|
||||
}
|
||||
|
||||
const char* Backend::uri() const
|
||||
{
|
||||
return m_uri.c_str();
|
||||
}
|
||||
|
Reference in New Issue
Block a user