mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 02:45:22 +00:00
[thrift] TSocketPool::addServer, c++ version
Summary: Same thing as the previous PHP change. Also includes a new constructor for easy building of a TSocketPool with a single host (for later filling in via addServer) without extra std::vector boxing/unboxing. Reviewed By: mcslee Test Plan: Synapse c++ client at r62896 uses this. Revert: OK TracCamp Project: Thrift DiffCamp Revision: 909 git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665297 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
34b2926d5c
commit
d1372829e6
@ -33,7 +33,7 @@ TSocketPool::TSocketPool(const vector<string> &hosts,
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < hosts.size(); ++i) {
|
||||
servers_.push_back(pair<string, int>(hosts[i], ports[i]));
|
||||
addServer(hosts[i], ports[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,10 +47,24 @@ TSocketPool::TSocketPool(const vector<pair<string, int> > servers) : TSocket(),
|
||||
{
|
||||
}
|
||||
|
||||
TSocketPool::TSocketPool(const string& host, int port) : TSocket(),
|
||||
numRetries_(1),
|
||||
retryInterval_(60),
|
||||
maxConsecutiveFailures_(1),
|
||||
randomize_(true),
|
||||
alwaysTryLast_(true)
|
||||
{
|
||||
addServer(host, port);
|
||||
}
|
||||
|
||||
TSocketPool::~TSocketPool() {
|
||||
close();
|
||||
}
|
||||
|
||||
void TSocketPool::addServer(const string& host, int port) {
|
||||
servers_.push_back(pair<string, int>(host, port));
|
||||
}
|
||||
|
||||
void TSocketPool::setNumRetries(int numRetries) {
|
||||
numRetries_ = numRetries;
|
||||
}
|
||||
|
@ -36,11 +36,24 @@ class TSocketPool : public TSocket {
|
||||
*/
|
||||
TSocketPool(const std::vector<std::pair<std::string, int> > servers);
|
||||
|
||||
/**
|
||||
* Socket pool constructor
|
||||
*
|
||||
* @param host single host
|
||||
* @param port single port
|
||||
*/
|
||||
TSocketPool(const std::string& host, int port);
|
||||
|
||||
/**
|
||||
* Destroyes the socket object, closing it if necessary.
|
||||
*/
|
||||
virtual ~TSocketPool();
|
||||
|
||||
/**
|
||||
* Add a server to the pool
|
||||
*/
|
||||
void addServer(const std::string& host, int port);
|
||||
|
||||
/**
|
||||
* Sets how many times to keep retrying a host in the connect function.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user