Fix redis cluster usage

This commit is contained in:
Grant Limberg 2022-04-28 13:05:02 -07:00
parent ff18bacd94
commit 1c700b7b41
No known key found for this signature in database
GPG key ID: 8F2F97D3BE8D7735

View file

@ -28,7 +28,7 @@
#include <chrono> #include <chrono>
// #define ZT_TRACE 1 // #define REDIS_TRACE 1
using json = nlohmann::json; using json = nlohmann::json;
@ -950,18 +950,18 @@ void PostgreSQL::_membersWatcher_Redis() {
} }
if (!result.empty()) { if (!result.empty()) {
for (auto element : result) { for (auto element : result) {
#ifdef ZT_TRACE #ifdef REDIS_TRACE
fprintf(stdout, "Received notification from: %s\n", element.first.c_str()); fprintf(stdout, "Received notification from: %s\n", element.first.c_str());
#endif #endif
for (auto rec : element.second) { for (auto rec : element.second) {
std::string id = rec.first; std::string id = rec.first;
auto attrs = rec.second; auto attrs = rec.second;
#ifdef ZT_TRACE #ifdef REDIS_TRACE
fprintf(stdout, "Record ID: %s\n", id.c_str()); fprintf(stdout, "Record ID: %s\n", id.c_str());
fprintf(stdout, "attrs len: %lu\n", attrs.size()); fprintf(stdout, "attrs len: %lu\n", attrs.size());
#endif #endif
for (auto a : attrs) { for (auto a : attrs) {
#ifdef ZT_TRACE #ifdef REDIS_TRACE
fprintf(stdout, "key: %s\nvalue: %s\n", a.first.c_str(), a.second.c_str()); fprintf(stdout, "key: %s\nvalue: %s\n", a.first.c_str(), a.second.c_str());
#endif #endif
try { try {
@ -1039,18 +1039,18 @@ void PostgreSQL::_networksWatcher_Redis() {
if (!result.empty()) { if (!result.empty()) {
for (auto element : result) { for (auto element : result) {
#ifdef ZT_TRACE #ifdef REDIS_TRACE
fprintf(stdout, "Received notification from: %s\n", element.first.c_str()); fprintf(stdout, "Received notification from: %s\n", element.first.c_str());
#endif #endif
for (auto rec : element.second) { for (auto rec : element.second) {
std::string id = rec.first; std::string id = rec.first;
auto attrs = rec.second; auto attrs = rec.second;
#ifdef ZT_TRACE #ifdef REDIS_TRACE
fprintf(stdout, "Record ID: %s\n", id.c_str()); fprintf(stdout, "Record ID: %s\n", id.c_str());
fprintf(stdout, "attrs len: %lu\n", attrs.size()); fprintf(stdout, "attrs len: %lu\n", attrs.size());
#endif #endif
for (auto a : attrs) { for (auto a : attrs) {
#ifdef ZT_TRACE #ifdef REDIS_TRACE
fprintf(stdout, "key: %s\nvalue: %s\n", a.first.c_str(), a.second.c_str()); fprintf(stdout, "key: %s\nvalue: %s\n", a.first.c_str(), a.second.c_str());
#endif #endif
try { try {
@ -1515,7 +1515,7 @@ void PostgreSQL::onlineNotification_Redis()
} }
} }
} catch (sw::redis::Error &e) { } catch (sw::redis::Error &e) {
#ifdef ZT_TRACE #ifdef REDIS_TRACE
fprintf(stderr, "Error in online notification thread (redis): %s\n", e.what()); fprintf(stderr, "Error in online notification thread (redis): %s\n", e.what());
#endif #endif
} }