mac deps
This commit is contained in:
parent
8f3a0b17ad
commit
d699116795
53 changed files with 434 additions and 15121 deletions
|
@ -78,6 +78,8 @@ PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, R
|
|||
, _waitNoticePrinted(false)
|
||||
, _listenPort(listenPort)
|
||||
, _rc(rc)
|
||||
, _redis(NULL)
|
||||
, _cluster(NULL)
|
||||
{
|
||||
char myAddress[64];
|
||||
_myAddressStr = myId.address().toString(myAddress);
|
||||
|
@ -113,6 +115,21 @@ PostgreSQL::PostgreSQL(const Identity &myId, const char *path, int listenPort, R
|
|||
PQfinish(conn);
|
||||
conn = NULL;
|
||||
|
||||
if (_rc != NULL) {
|
||||
sw::redis::ConnectionOptions opts;
|
||||
sw::redis::ConnectionPoolOptions poolOpts;
|
||||
opts.host = _rc->hostname;
|
||||
opts.port = _rc->port;
|
||||
opts.password = _rc->password;
|
||||
opts.db = 0;
|
||||
poolOpts.size = 10;
|
||||
if (_rc->clusterMode) {
|
||||
_cluster = new sw::redis::RedisCluster(opts, poolOpts);
|
||||
} else {
|
||||
_redis = new sw::redis::Redis(opts, poolOpts);
|
||||
}
|
||||
}
|
||||
|
||||
_readyLock.lock();
|
||||
_heartbeatThread = std::thread(&PostgreSQL::heartbeat, this);
|
||||
_membersDbWatcher = std::thread(&PostgreSQL::membersDbWatcher, this);
|
||||
|
@ -128,6 +145,8 @@ PostgreSQL::~PostgreSQL()
|
|||
_run = 0;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
|
||||
|
||||
_heartbeatThread.join();
|
||||
_membersDbWatcher.join();
|
||||
_networksDbWatcher.join();
|
||||
|
@ -135,7 +154,8 @@ PostgreSQL::~PostgreSQL()
|
|||
_commitThread[i].join();
|
||||
}
|
||||
_onlineNotificationThread.join();
|
||||
|
||||
delete _redis;
|
||||
delete _cluster;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#define ZT_CENTRAL_CONTROLLER_COMMIT_THREADS 4
|
||||
|
||||
#include <redis++/redis++.h>
|
||||
|
||||
extern "C" {
|
||||
typedef struct pg_conn PGconn;
|
||||
}
|
||||
|
@ -98,6 +100,8 @@ private:
|
|||
int _listenPort;
|
||||
|
||||
RedisConfig *_rc;
|
||||
sw::redis::Redis *_redis;
|
||||
sw::redis::RedisCluster *_cluster;
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
|
15
controller/Redis.hpp
Normal file
15
controller/Redis.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef ZT_CONTROLLER_REDIS_HPP
|
||||
#define ZT_CONTROLLER_REDIS_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ZeroTier {
|
||||
struct RedisConfig {
|
||||
std::string hostname;
|
||||
int port;
|
||||
std::string password;
|
||||
bool clusterMode;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue