1 #ifndef _CONNECTION_MANAGER_H 2 #define _CONNECTION_MANAGER_H 15 #include <plugin_api.h> 19 #include <config_category.h> 21 #define NO_DESCRIPTORS_PER_DB 3 // 3 deascriptors per database when using WAL mode 22 #define DESCRIPTOR_THRESHOLD 75 // Percentage of descriptors that can be used on database connections 36 bool attachNewDb(std::string &path, std::string &alias);
41 void setError(
const char *,
const char *,
bool);
47 void setVacuumInterval(
long hours)
49 m_vacuumInterval = 60 * 60 * hours;
63 int SQLExec(sqlite3 *dbHandle,
const char *sqlCmd,
65 void noConnectionsDiagnostic();
68 std::list<Connection *> idle;
69 std::list<Connection *> inUse;
76 std::thread *m_background;
77 long m_vacuumInterval;
78 unsigned int m_descriptorLimit;
79 unsigned int m_attachedDatabases;
bool attachNewDb(std::string &path, std::string &alias)
Attach a database to all the connections, idle and inuse.
Definition: connection_manager.cpp:233
Definition: config_category.h:56
void growPool(unsigned int)
Grow the connection pool by the number of connections specified.
Definition: connection_manager.cpp:59
unsigned int shrinkPool(unsigned int)
Attempt to shrink the number of connections in the idle pool.
Definition: connection_manager.cpp:82
Connection * allocate()
Allocate a connection from the idle pool.
Definition: connection_manager.cpp:110
Singleton class to manage Postgres connection pool.
Definition: connection_manager.h:22
bool detachNewDb(std::string &alias)
Detach a database from all the connections.
Definition: connection_manager.cpp:308
void shutdown()
Called at shutdown.
Definition: connection_manager.cpp:35
static ConnectionManager * getInstance()
Return the singleton instance of the connection manager.
Definition: connection_manager.cpp:44
bool attachRequestNewDb(int newDbId, sqlite3 *dbHandle)
Adds to all the connections a request to attach a database.
Definition: connection_manager.cpp:373
bool allowMoreDatabases()
Determine if we can allow another database to be created and attached to all the connections.
Definition: connection_manager.cpp:561
void release(Connection *)
Release a connection back to the idle pool for reallocation.
Definition: connection_manager.cpp:142
void background()
Background thread used to execute periodic tasks and oversee the database activity.
Definition: connection_manager.cpp:535
void setError(const char *, const char *, bool)
Set the last error information for a plugin.
Definition: connection_manager.cpp:159
A class to monitor the free disk space used to store the various storage databases.
Definition: disk_monitor.h:22
std::string getDBConfiguration()
Return the pragma configuration for the database.
Definition: connection_manager.cpp:595
Definition: connection.h:32
Structure used by plugins to return error information.
Definition: plugin_api.h:44