A generic interface wrapping multiple backends to provide a consistent pubsub API.
Project description
A generic interface wrapping multiple backends to provide a consistent pubsub API.
Installation
pip install aio-pubsub
# for redis backend
pip install aio-pubsub[aioredis]
# for postgresql backend
pip install aio-pubsub[aiopg]
Usage
To use it, you need to implement your pubsub implementation from interfaces or use backends from aio_pubsub.backends package
from aio_pubsub.backends.memory import MemoryPubSub
pubsub = MemoryPubSub()
# Create subscriber
subscriber = await pubsub.subscribe("a_chan")
# Push message
await pubsub.publish("a_chan", "hello world!")
await pubsub.publish("a_chan", "hello universe!")
# And listening channel
try:
async for message in subscriber:
print(message, flush=True)
except KeyboardInterrupt:
print("Finish listening")
Supported backends
Disclaimer: I would not advise you to use this backend, because it is shown only for testing purposes. Better develop your own implementation.
memory
redis
postgresql
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aio_pubsub-0.3.0.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for aio_pubsub-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | faad5aaa91dd901494f8d575f86cc955dba4b41ad8bdbcafa77955592e5e02d9 |
|
MD5 | 08153505c2e1399428cd2d30cf45ca9f |
|
BLAKE2b-256 | 2a9db6df7fc99c036fcbfa971108984270835fb8f32f14c9497ce8be59ed8700 |