17 #ifndef DBServer_PostgreSQL_H_
18 #define DBServer_PostgreSQL_H_
20 #include <unordered_map>
22 #include "UniSetTypes.h"
23 #include "PostgreSQLInterface.h"
63 static std::shared_ptr<DBServer_PostgreSQL>
init_dbserver(
int argc,
const char*
const* argv,
const std::string& prefix =
"pgsql" );
66 static void help_print(
int argc,
const char*
const* argv );
68 inline std::shared_ptr<LogAgregator> logAggregator()
72 inline std::shared_ptr<DebugStream> log()
78 typedef std::unordered_map<int, std::string> DBTableMap;
80 virtual void initDBServer()
override;
81 virtual void initDB( std::shared_ptr<PostgreSQLInterface>& db ) {};
82 virtual void initDBTableMap(DBTableMap& tblMap) {};
88 virtual void sigterm(
int signo )
override;
90 bool writeToBase(
const string& query );
91 void createTables( std::shared_ptr<PostgreSQLInterface>& db );
93 inline std::string tblName(
int key)
106 std::shared_ptr<PostgreSQLInterface> db;
107 int PingTime = { 15000 };
113 typedef std::queue<std::string> QueryBuffer;
117 bool lastRemove = {
false };
123 const std::list<std::string> tblcols = {
"date",
"time",
"time_usec",
"sensor_id",
"value",
"node" };
125 typedef std::vector<PostgreSQLInterface::Record> InsertBuffer;
127 size_t ibufSize = { 0 };
128 size_t ibufMaxSize = { 2000 };
129 timeout_t ibufSyncTimeout = { 15000 };
130 void flushInsertBuffer();
131 float ibufOverflowCleanFactor = { 0.5 };