2 #include "../acl_cpp_define.hpp" 3 #include "../stdlib/string.hpp" 4 #include "../stdlib/locker.hpp" 5 #include "../stdlib/noncopyable.hpp" 15 class connect_monitor;
19 std::vector<connect_pool*>
pools;
56 void bind_thread(
bool yes);
72 void init(
const char* default_addr,
const char* addr_list,
73 size_t count,
int conn_timeout = 30,
int rw_timeout = 30);
84 void set(
const char* addr,
size_t count,
85 int conn_timeout = 30,
int rw_timeout = 30);
94 const conn_config* get_config(
const char* addr,
bool use_first =
false);
101 void set_retry_inter(
int n);
108 void set_idle_ttl(time_t ttl);
114 void set_check_inter(
int n);
121 void remove(
const char* addr);
132 connect_pool* get(
const char* addr,
bool exclusive =
true,
133 bool restore =
false);
154 virtual connect_pool* peek(
const char* key,
bool exclusive =
true);
170 std::vector<connect_pool*>& get_pools(
void);
178 size_t check_idle(
size_t step,
size_t* left = NULL);
184 size_t size(
void)
const;
193 return default_pool_;
199 void statistics(
void);
225 void set_pools_status(
const char* addr,
bool alive);
236 size_t count,
size_t idx) = 0;
243 typedef std::map<unsigned long, conns_pools*>
manager_t;
262 void set_service_list(
const char* addr_list,
int count,
263 int conn_timeout,
int rw_timeout);
266 void create_pools_for(
pools_t& pools);
268 void remove(
pools_t& pools,
const char* addr);
269 void set_status(
pools_t& pools,
const char* addr,
bool alive);
271 unsigned long get_id(
void)
const;
272 void get_key(
const char* addr,
string& key);
273 void get_addr(
const char* key,
string& addr);
277 static void thread_oninit(
void);
279 static void thread_onexit(
void* ctx);
std::vector< connect_pool * > pools_t
std::vector< connect_pool * > pools
connect_pool * get_default_pool(void)
std::map< string, conn_config > addrs_
std::map< unsigned long, conns_pools * > manager_t
connect_pool * default_pool_
connect_monitor * monitor_
pools_t::const_iterator pools_cit
manager_t::const_iterator manager_cit
struct ACL_EVENT ACL_EVENT
pools_t::iterator pools_it
manager_t::iterator manager_it