[DB] Use a single shared pool of connections to the database

This commit is contained in:
emeric
2015-08-19 13:31:50 +02:00
parent 4b35e03ef8
commit e18221689f
23 changed files with 89 additions and 62 deletions
+2 -3
View File
@@ -38,10 +38,9 @@ static std::vector<std::string> splitStrings(const std::string& source)
namespace Service {
DatabaseUpdateService::DatabaseUpdateService()
DatabaseUpdateService::DatabaseUpdateService(Wt::Dbo::SqlConnectionPool &connectionPool)
: _metadataParser(),
_databaseUpdater( ConfigReader::instance().getString("main.database.path"),
_metadataParser)
_databaseUpdater( connectionPool, _metadataParser)
{
_databaseUpdater.setAudioExtensions(splitStrings(ConfigReader::instance().getString("main.database.audio_extensions")));
_databaseUpdater.setVideoExtensions(splitStrings(ConfigReader::instance().getString("main.database.video_extensions")));
+1 -1
View File
@@ -36,7 +36,7 @@ class DatabaseUpdateService : public Service
typedef std::shared_ptr<DatabaseUpdateService> pointer;
DatabaseUpdateService();
DatabaseUpdateService(Wt::Dbo::SqlConnectionPool &connectionPool);
// Service interface
void start(void);
+2 -2
View File
@@ -26,7 +26,7 @@
namespace Service {
LmsAPIService::LmsAPIService()
LmsAPIService::LmsAPIService(Wt::Dbo::SqlConnectionPool& connectionPool)
: _server(
boost::asio::ip::tcp::endpoint(
boost::asio::ip::address::from_string(ConfigReader::instance().getString("remote.listen-endpoint.addr")),
@@ -34,7 +34,7 @@ LmsAPIService::LmsAPIService()
ConfigReader::instance().getString("remote.ssl-crypto.cert"),
ConfigReader::instance().getString("remote.ssl-crypto.key"),
ConfigReader::instance().getString("remote.ssl-crypto.dh"),
ConfigReader::instance().getString("main.database.path"))
connectionPool)
{
}
+2 -2
View File
@@ -20,7 +20,7 @@
#ifndef REMOTE_SERVER_SERVICE_HPP
#define REMOTE_SERVER_SERVICE_HPP
#include <boost/filesystem.hpp>
#include <Wt/Dbo/SqlConnectionPool>
#include "config/config.h"
@@ -34,7 +34,7 @@ class LmsAPIService : public Service
{
public:
LmsAPIService();
LmsAPIService(Wt::Dbo::SqlConnectionPool& connectionPool);
void start(void);
void stop(void);
+4 -2
View File
@@ -17,6 +17,8 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wt/Dbo/SqlConnectionPool>
#include "logger/Logger.hpp"
#include "UserInterfaceService.hpp"
@@ -26,7 +28,7 @@
namespace Service {
UserInterfaceService::UserInterfaceService( boost::filesystem::path runAppPath)
UserInterfaceService::UserInterfaceService( boost::filesystem::path runAppPath, Wt::Dbo::SqlConnectionPool& connectionPool)
: _server(runAppPath.string())
{
std::vector<std::string> args;
@@ -54,7 +56,7 @@ UserInterfaceService::UserInterfaceService( boost::filesystem::path runAppPath)
_server.setServerConfiguration (argc, const_cast<char**>(argv));
// bind entry point
_server.addEntryPoint(Wt::Application, boost::bind(UserInterface::LmsApplication::create, _1, ConfigReader::instance().getString("main.database.path")));
_server.addEntryPoint(Wt::Application, boost::bind(UserInterface::LmsApplication::create, _1, boost::ref(connectionPool)));
}
+1 -1
View File
@@ -32,7 +32,7 @@ class UserInterfaceService : public Service
{
public:
UserInterfaceService(boost::filesystem::path runAppPath);
UserInterfaceService(boost::filesystem::path runAppPath, Wt::Dbo::SqlConnectionPool& connectionPool);
void start(void);
void stop(void);