diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ffb6b4a8..83f69fedb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,14 @@ if (REDISPP_FOUND) set(REDISPP_WITH_TLS ON) endif() unset(CONTENTS) + + # Redis++ had a breaking change between 1.3.6 and 1.3.7 + # Detect this change by checking if the new header exists + # + # See https://github.com/sewenew/redis-plus-plus/commit/192ebae13583ff0611e2d7666a9c1e98a2a0dc86 + if (EXISTS "${REDISPP_INCLUDEDIR}/sw/redis++/redis_uri.h") + set(REDISPP_WITH_URI ON) + endif() endif() # Check if libwebsockets is build with deflate extension diff --git a/include/villas/node/config.hpp.in b/include/villas/node/config.hpp.in index 68e9a245a..16281314f 100644 --- a/include/villas/node/config.hpp.in +++ b/include/villas/node/config.hpp.in @@ -58,3 +58,4 @@ /* Library features */ #cmakedefine LWS_DEFLATE_FOUND #cmakedefine REDISPP_WITH_TLS +#cmakedefine REDISPP_WITH_URI diff --git a/include/villas/nodes/redis_helpers.hpp b/include/villas/nodes/redis_helpers.hpp index e30c291a4..d35018ed5 100644 --- a/include/villas/nodes/redis_helpers.hpp +++ b/include/villas/nodes/redis_helpers.hpp @@ -188,3 +188,20 @@ OStream &operator<<(OStream &os, const enum villas::node::RedisMode &m) return os; } + +namespace villas { +namespace node { +#ifdef REDISPP_WITH_URI + sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) + { + auto u = sw::redis::Uri { uri }; + return u.connection_options(); + } +#else + sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) + { + return sw::redis::ConnectionOptions { uri }; + } +#endif +} // node +} // villas diff --git a/lib/nodes/redis.cpp b/lib/nodes/redis.cpp index 0336a5255..ec33a83ca 100644 --- a/lib/nodes/redis.cpp +++ b/lib/nodes/redis.cpp @@ -418,7 +418,7 @@ int villas::node::redis_parse(NodeCompat *n, json_t *json) /* Connection options */ if (uri) - r->options = sw::redis::ConnectionOptions(uri); + r->options = make_redis_connection_options(uri); if (db >= 0) r->options.db = db;