aka. Redis Event Queue
An extremely simple, minimalistic library for handling events published to Redis.
Reeq currently uses Redis Pub/Sub, where messages are delivered following at-most-once semantics. That is, messages will get lost while your subscriber is offline, which is not an optimal behavior for the use cases that reeq is targeting. Instead, we might want to switch to Redis Streams with consumer groups instead, which provide persistent messages.
You might ask how reeq compares to tools such as rq or Celery. Reeq is way more lightweight, a bit more "low-level", but also way less capable. Reeq essentially only provides an event bus on top of Redis, while the aforementioned tools cover serialization, scheduling, task chaining, message retrial and a lot more. Another difference is the fact that job / task queues like rq or Celery usually impose "uni-directional" message flow, from your application to the workers, while reeq is built for use cases that require bi-directional communication between two "coequal" programs.
pip install git+https://github.com/muety/reeq.gitfrom reeq import reeq
# listen for event wildcard
@reeq.listener('foo.bar.*')
def handle1(event: str, payload: Dict[str, Any]):
logging.info(f'[1] Got event "{event}" with payload: {payload}')
# listen for specific event
@reeq.listener('foo.bar.baz')
def handle2(event: str, payload: Dict[str, Any]):
logging.info(f'[2] Got event "{event}" with payload: {payload}')
if __name__ == '__main__':
reeq.init('redis://localhost')
# publish event
reeq.publish('foo.bar.baz', '{"value": 1}')MIT