2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2017-04-27 21:46:28 +08:00
|
|
|
|
#include <map>
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stdlib/string.hpp"
|
|
|
|
|
#include "../connpool/connect_manager.hpp"
|
2017-04-27 21:46:28 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_DB_DISABLE)
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2017-04-27 21:46:28 +08:00
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
class pgsql_conf;
|
|
|
|
|
|
|
|
|
|
class ACL_CPP_API pgsql_manager : public connect_manager
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
pgsql_manager(time_t idle_ttl = 120);
|
|
|
|
|
~pgsql_manager();
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2017-04-27 21:46:28 +08:00
|
|
|
|
* @param conf {const pgsql_conf&}
|
|
|
|
|
* @return {pgsql_manager&}
|
|
|
|
|
*/
|
|
|
|
|
pgsql_manager& add(const pgsql_conf& conf);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> connect_manager <EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param addr {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ip:port
|
|
|
|
|
* @param count {size_t} <EFBFBD><EFBFBD><EFBFBD>ӳصĴ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD>ֵΪ 0 ʱ<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param idx {size_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳض<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>±<EFBFBD>λ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD> 0 <EFBFBD><EFBFBD>ʼ)
|
|
|
|
|
* @return {connect_pool*} <EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳض<EFBFBD><EFBFBD><EFBFBD>
|
2017-04-27 21:46:28 +08:00
|
|
|
|
*/
|
|
|
|
|
connect_pool* create_pool(const char* addr, size_t count, size_t idx);
|
|
|
|
|
|
|
|
|
|
private:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
time_t idle_ttl_; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>ӵĿ<D3B5><C4BF>й<EFBFBD><D0B9><EFBFBD>ʱ<EFBFBD><CAB1>
|
2017-04-27 21:46:28 +08:00
|
|
|
|
std::map<string, pgsql_conf*> dbs_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_DB_DISABLE)
|