Resolve "unify redis connector"
Description
Unification of RedisConnector
, to not have producer
and consumer
dichotomy anymore.
ConnectorBase
is refactored as well: it is now made of 2 interfaces, one for pub/sub
and one for storing values.
The new PubSubInterface
has 3 main methods:
-
send()
: send a message to listeners -
register()
: same signature as previousconsumer
, except some unused args have been removed -
poll_messages()
: handle incoming messages beforetimeout
seconds
Each Connector
has to implement the methods to be as efficient as possible.
Related Issues
RedisConnector
Improvements of The way to wait for messages, in a loop with a short sleep time, can be improved by
blocking on the socket read. get_message
calls in a loop with a timeout on socket
does the trick.
In addition, message reception and message handling are now separated, each within its own thread. A thread-safe FIFO makes the link between the two tasks. This ensures the best performance for receiving messages, and treatment depends then on the code executed by callbacks.
Callbacks are stored using louie.safe_ref
: this ensures an object is not retained
by our dispatching code, since it is stored internally as a weak reference.
catch_connection_error
Removal of Previously the catch_connection_error
decorator was displaying a message, and
swallowing connection errors when talking to Redis.
The new code removes this decorator, this makes error management more explicit ;
parts of the code are changed accordingly, to react in case of disconnect/reconnect.
Type of Change
- refactoring BREAKING CHANGES
Closes #127 (closed)