1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

node-redis: Work around breaking change in redis-plus-plus

Signed-off-by: Philipp Jungkamp <Philipp.Jungkamp@opal-rt.com>
This commit is contained in:
Philipp Jungkamp 2023-06-21 10:06:52 +02:00
parent 398497300d
commit 9d28079d24
4 changed files with 27 additions and 1 deletions

View file

@ -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

View file

@ -58,3 +58,4 @@
/* Library features */
#cmakedefine LWS_DEFLATE_FOUND
#cmakedefine REDISPP_WITH_TLS
#cmakedefine REDISPP_WITH_URI

View file

@ -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

View file

@ -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;