diff options
| author | Grant Limberg <[email protected]> | 2020-05-11 16:02:49 -0700 |
|---|---|---|
| committer | Grant Limberg <[email protected]> | 2020-05-11 16:48:14 -0700 |
| commit | d699116795b5e1db30798b8abb59b4fa3e70ea13 (patch) | |
| tree | 7b6d7ad208902ce61f48ad1964ae2f365f59dff6 /controller/PostgreSQL.cpp | |
| parent | 8f3a0b17ad95b298b6435ac68cd53fbfb630dd97 (diff) | |
mac deps
Diffstat (limited to 'controller/PostgreSQL.cpp')
| -rw-r--r-- | controller/PostgreSQL.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index 91cbdb78..0640cb8e 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -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; } |
