mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
It builds!
This commit is contained in:
parent
250b1aef79
commit
b441d4ec99
2 changed files with 18 additions and 10 deletions
|
@ -3,8 +3,9 @@
|
|||
#include "CharaDbConnection.h"
|
||||
#include "DbWorkerPool.h"
|
||||
#include "Logging/Logger.h"
|
||||
#include "Framework.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Framework g_fw;
|
||||
|
||||
Core::Db::DbLoader::DbLoader()
|
||||
{
|
||||
|
@ -16,12 +17,14 @@ Core::Db::DbLoader& Core::Db::DbLoader::addDb( Core::Db::DbWorkerPool< T >& pool
|
|||
|
||||
m_open.push([this, info, &pool]() -> bool
|
||||
{
|
||||
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
const uint8_t asyncThreads = info.asyncThreads;
|
||||
const uint8_t synchThreads = info.syncThreads;
|
||||
|
||||
if( asyncThreads < 1 || asyncThreads > 32 )
|
||||
{
|
||||
g_log.error( "database: invalid number of worker threads specified. Please pick a value between 1 and 32." );
|
||||
pLog->error( "database: invalid number of worker threads specified. Please pick a value between 1 and 32." );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -36,7 +39,7 @@ Core::Db::DbLoader& Core::Db::DbLoader::addDb( Core::Db::DbWorkerPool< T >& pool
|
|||
|
||||
if( error )
|
||||
{
|
||||
g_log.error( "DatabasePool failed to open." );
|
||||
pLog->error( "DatabasePool failed to open." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +53,8 @@ Core::Db::DbLoader& Core::Db::DbLoader::addDb( Core::Db::DbWorkerPool< T >& pool
|
|||
{
|
||||
if( !pool.prepareStatements() )
|
||||
{
|
||||
g_log.error( "Could not prepare statements of the database, see log for details." );
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
pLog->error( "Could not prepare statements of the database, see log for details." );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -104,5 +108,5 @@ bool Core::Db::DbLoader::process( std::queue< Predicate >& queue )
|
|||
template
|
||||
Core::Db::DbLoader&
|
||||
Core::Db::DbLoader::addDb< Core::Db::CharaDbConnection >( Core::Db::DbWorkerPool< Core::Db::CharaDbConnection >&,
|
||||
const ConnectionInfo& );
|
||||
const ConnectionInfo& );
|
||||
|
||||
|
|
|
@ -6,9 +6,11 @@
|
|||
#include "Operation.h"
|
||||
#include "CharaDbConnection.h"
|
||||
#include <boost/make_shared.hpp>
|
||||
#include "Framework.h"
|
||||
|
||||
#include "Logging/Logger.h"
|
||||
extern Core::Logger g_log;
|
||||
|
||||
extern Core::Framework g_fw;
|
||||
|
||||
class PingOperation : public Core::Db::Operation
|
||||
{
|
||||
|
@ -46,7 +48,8 @@ void Core::Db::DbWorkerPool< T >::setConnectionInfo( const ConnectionInfo& info,
|
|||
template< class T >
|
||||
uint32_t Core::Db::DbWorkerPool< T >::open()
|
||||
{
|
||||
g_log.info( "[DbPool] Opening DatabasePool " + getDatabaseName() +
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
pLog->info( "[DbPool] Opening DatabasePool " + getDatabaseName() +
|
||||
" Asynchronous connections: " + std::to_string( m_asyncThreads ) +
|
||||
" Synchronous connections: " + std::to_string( m_synchThreads ) );
|
||||
|
||||
|
@ -59,7 +62,7 @@ uint32_t Core::Db::DbWorkerPool< T >::open()
|
|||
|
||||
if( !error )
|
||||
{
|
||||
g_log.info( "[DbPool] DatabasePool " + getDatabaseName() + " opened successfully. " +
|
||||
pLog->info( "[DbPool] DatabasePool " + getDatabaseName() + " opened successfully. " +
|
||||
std::to_string( ( m_connections[IDX_SYNCH].size() + m_connections[IDX_ASYNC].size() ) ) +
|
||||
" total connections running." );
|
||||
}
|
||||
|
@ -70,10 +73,11 @@ uint32_t Core::Db::DbWorkerPool< T >::open()
|
|||
template< class T >
|
||||
void Core::Db::DbWorkerPool< T >::close()
|
||||
{
|
||||
g_log.info("[DbPool] Closing down DatabasePool " + getDatabaseName() );
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
pLog->info("[DbPool] Closing down DatabasePool " + getDatabaseName() );
|
||||
m_connections[IDX_ASYNC].clear();
|
||||
m_connections[IDX_SYNCH].clear();
|
||||
g_log.info("[DbPool] All connections on DatabasePool " + getDatabaseName() + "closed." );
|
||||
pLog->info("[DbPool] All connections on DatabasePool " + getDatabaseName() + "closed." );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
|
|
Loading…
Add table
Reference in a new issue