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 };
Definition: DBServer_PostgreSQL.h:101
Definition: CallbackTimer.h:29
Definition: DBServer_PostgreSQL.h:102
virtual void sigterm(int signo) override
Definition: DBServer_PostgreSQL.cc:464
bool activate
Definition: DBServer_PostgreSQL.h:111
Definition: DBServer.h:51
Definition: MessageType.h:166
Definition: MessageType.h:232
static std::shared_ptr< DBServer_PostgreSQL > init_dbserver(int argc, const char *const *argv, const std::string &prefix="pgsql")
Definition: DBServer_PostgreSQL.cc:478
Timers
Definition: DBServer_PostgreSQL.h:98
The DBServer_PostgreSQL class Реализация работы с PostgreSQL.
Definition: DBServer_PostgreSQL.h:54
Definition: DBServer_PostgreSQL.h:100
Definition: MessageType.h:122
static void help_print(int argc, const char *const *argv)
Definition: DBServer_PostgreSQL.cc:502
Definition: MessageType.h:209
static KeyType key(const uniset::ObjectId id, const uniset::ObjectId node)
Definition: UniSetTypes.h:72
long ObjectId
Definition: UniSetTypes_i.idl:30