2021-12-13 22:06:46 +00:00
|
|
|
#include "MySQLHelpers.h"
|
|
|
|
|
|
|
|
#if USE_MYSQL
|
|
|
|
#include <mysqlxx/PoolWithFailover.h>
|
|
|
|
#include <Storages/ExternalDataSourceConfiguration.h>
|
|
|
|
#include <Storages/MySQL/MySQLSettings.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-12-27 14:41:37 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int BAD_ARGUMENTS;
|
|
|
|
}
|
|
|
|
|
2021-12-13 22:06:46 +00:00
|
|
|
mysqlxx::PoolWithFailover
|
|
|
|
createMySQLPoolWithFailover(const StorageMySQLConfiguration & configuration, const MySQLSettings & mysql_settings)
|
|
|
|
{
|
2021-12-27 14:41:37 +00:00
|
|
|
if (!mysql_settings.connection_pool_size)
|
|
|
|
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Connection pool cannot have zero size");
|
|
|
|
|
2021-12-13 22:06:46 +00:00
|
|
|
return mysqlxx::PoolWithFailover(
|
|
|
|
configuration.database, configuration.addresses, configuration.username, configuration.password,
|
|
|
|
MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS,
|
|
|
|
mysql_settings.connection_pool_size,
|
|
|
|
mysql_settings.connection_max_tries,
|
|
|
|
mysql_settings.connection_wait_timeout,
|
|
|
|
mysql_settings.connect_timeout,
|
|
|
|
mysql_settings.read_write_timeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|