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
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
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.2.0.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for aio_pubsub-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc37841f0f8e47e552d150a0d5bf2dd79767bbd1ec904fb6d578fb3a325a6210 |
|
MD5 | 9c3f525b1d0ea6b3eb8607132406b0bd |
|
BLAKE2b-256 | c71ee5d3a08a65e23a5c6fafb12ab7787494f38e2085fdc67b74802c7e0ff35f |