acl/lib_acl_cpp/include/acl_cpp/db/pgsql_manager.hpp

44 lines
1.1 KiB
C++
Raw Normal View History

#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
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_DB_DISABLE)
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();
/**
* <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:
/**
* <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:
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
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_DB_DISABLE)