Add helper functions and default parameters
Added some helper functions into the MaxScale class and default parameters into the connection creation functions. Also made the ip() function const correct.
This commit is contained in:
parent
464d52453b
commit
36c960a141
@ -71,7 +71,7 @@ MYSQL* open_conn_db_timeout(int port, std::string ip, std::string db, std::strin
|
||||
* @return MYSQL struct
|
||||
*/
|
||||
static MYSQL* open_conn_db(int port, std::string ip, std::string db, std::string user, std::string password,
|
||||
bool ssl)
|
||||
bool ssl = false)
|
||||
{
|
||||
return open_conn_db_flags(port, ip, db, user, password, CLIENT_MULTI_STATEMENTS, ssl);
|
||||
}
|
||||
@ -87,7 +87,7 @@ static MYSQL* open_conn_db(int port, std::string ip, std::string db, std::string
|
||||
*
|
||||
* @return MYSQL struct
|
||||
*/
|
||||
static MYSQL* open_conn(int port, std::string ip, std::string user, std::string password, bool ssl)
|
||||
static MYSQL* open_conn(int port, std::string ip, std::string user, std::string password, bool ssl = false)
|
||||
{
|
||||
return open_conn_db(port, ip.c_str(), "test", user.c_str(), password.c_str(), ssl);
|
||||
}
|
||||
@ -103,7 +103,7 @@ static MYSQL* open_conn(int port, std::string ip, std::string user, std::string
|
||||
*
|
||||
* @return MYSQL struct
|
||||
*/
|
||||
static MYSQL* open_conn_no_db(int port, std::string ip, std::string user, std::string password, bool ssl)
|
||||
static MYSQL* open_conn_no_db(int port, std::string ip, std::string user, std::string password, bool ssl = false)
|
||||
{
|
||||
return open_conn_db_flags(port, ip, "", user, password, CLIENT_MULTI_STATEMENTS, ssl);
|
||||
}
|
||||
|
@ -417,3 +417,17 @@ StringSet Maxscales::get_server_status(const char* name, int m)
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
int Maxscales::port(enum service type, int m) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RWSPLIT:
|
||||
return rwsplit_port[m];
|
||||
case READCONN_MASTER:
|
||||
return readconn_master_port[m];
|
||||
case READCONN_SLAVE:
|
||||
return readconn_slave_port[m];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -8,6 +8,13 @@
|
||||
class Maxscales: public Nodes
|
||||
{
|
||||
public:
|
||||
enum service
|
||||
{
|
||||
RWSPLIT,
|
||||
READCONN_MASTER,
|
||||
READCONN_SLAVE
|
||||
};
|
||||
|
||||
Maxscales(const char *pref, const char *test_cwd, bool verbose);
|
||||
int read_env();
|
||||
|
||||
@ -26,6 +33,16 @@ public:
|
||||
*/
|
||||
int readconn_slave_port[256];
|
||||
|
||||
/**
|
||||
* @brief Get port number of a MaxScale service
|
||||
*
|
||||
* @param type Type of service
|
||||
* @param m MaxScale instance to use
|
||||
*
|
||||
* @return Port number of the service
|
||||
*/
|
||||
int port(enum service type = RWSPLIT, int m = 0) const;
|
||||
|
||||
/**
|
||||
* @brief binlog_port binlog router service port
|
||||
*/
|
||||
|
@ -467,7 +467,7 @@ int Nodes::read_basic_env()
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* Nodes::ip(int i) const
|
||||
const char* Nodes::ip(int i) const
|
||||
{
|
||||
return use_ipv6 ? (char*)IP6[i] : (char*)IP[i];
|
||||
return use_ipv6 ? IP6[i] : IP[i];
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
*
|
||||
* @return The current IP address
|
||||
*/
|
||||
char* ip(int i) const;
|
||||
const char* ip(int i = 0) const;
|
||||
|
||||
/**
|
||||
* @brief Generate command line to execute command on the node via ssh
|
||||
|
Loading…
x
Reference in New Issue
Block a user