Take DBAAS multi-channel publishing Redis modules into use
Following SDL APIs are defined so that multiple channel-event pairs can be
given as function argument but actual SDL implementation utilized such a DBAAS
(Redis) module what expect to get only one channel-event pair. Fix the
implementation of these SDL APIs to use the correct DBAAS module what support
multiple channel-event pairs:
* set_if_and_publish()
* set_if_not_exists_and_publish()
* remove_if_and_publish()
Please note that in runtime environment DBAAS service needs to run on DBAAS
image version 0.4.0 or newer. Older images do not have multiple channel-event
pairs support as a Redis module.
Updated also start_event_listener() and handle_events() description to
emphasize that channel-event subscription must be done before calling those
functions, otherwise open-source Redis client application could throw an
exception due to not having any subscription when it receives some event, for
example a ping event in case of the DBAAS Sentinel deployment.
Issue-ID: RIC-758
Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: I75d4e3316d7387b7a1a735fe3eb357de7ef794bb
diff --git a/ricsdl-package/ricsdl/backend/redis.py b/ricsdl-package/ricsdl/backend/redis.py
index c67be2d..c319bf0 100755
--- a/ricsdl-package/ricsdl/backend/redis.py
+++ b/ricsdl-package/ricsdl/backend/redis.py
@@ -205,7 +205,7 @@
values = self.__redis.mget(db_keys)
for idx, val in enumerate(values):
# return only key values, which has a value
- if val:
+ if val is not None:
ret[keys[idx]] = val
return ret
@@ -285,7 +285,7 @@
channels_and_events_prepared = []
channels_and_events_prepared, _ = self._prepare_channels(ns, channels_and_events)
with _map_to_sdl_exception():
- ret = self.__redis.execute_command("SETIEPUB", db_key, new_data, old_data,
+ ret = self.__redis.execute_command("SETIEMPUB", db_key, new_data, old_data,
*channels_and_events_prepared)
return ret == b"OK"
@@ -294,7 +294,7 @@
db_key = self._add_key_ns_prefix(ns, key)
channels_and_events_prepared, _ = self._prepare_channels(ns, channels_and_events)
with _map_to_sdl_exception():
- ret = self.__redis.execute_command("SETNXPUB", db_key, data,
+ ret = self.__redis.execute_command("SETNXMPUB", db_key, data,
*channels_and_events_prepared)
return ret == b"OK"
@@ -316,7 +316,7 @@
db_key = self._add_key_ns_prefix(ns, key)
channels_and_events_prepared, _ = self._prepare_channels(ns, channels_and_events)
with _map_to_sdl_exception():
- ret = self.__redis.execute_command("DELIEPUB", db_key, data,
+ ret = self.__redis.execute_command("DELIEMPUB", db_key, data,
*channels_and_events_prepared)
return bool(ret)