Add server state helper functions

Added helper functions that check various server states. This makes the
readwritesplit code easier to read as the function names convey the
intention better than the macro invokations.
This commit is contained in:
Markus Mäkelä
2017-06-19 13:30:53 +03:00
parent 37b6cf250d
commit d7543988ee
4 changed files with 49 additions and 14 deletions

View File

@ -279,6 +279,21 @@ bool Backend::is_closed() const
return m_closed;
}
bool Backend::is_master() const
{
return SERVER_IS_MASTER(m_backend->server);
}
bool Backend::is_slave() const
{
return SERVER_IS_SLAVE(m_backend->server);
}
bool Backend::is_relay() const
{
return SERVER_IS_RELAY_SERVER(m_backend->server);
}
bool Backend::has_failed() const
{
return m_state & FATAL_FAILURE;