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 details)
Built Distribution
File details
Details for the file aio_pubsub-0.3.0.tar.gz
.
File metadata
- Download URL: aio_pubsub-0.3.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dad264093e1feab45680728175afb81994ede3861ec2e368b9ef4d3453b2386 |
|
MD5 | b0e2a9d4408b4e3dcfc5ca6ee152e64b |
|
BLAKE2b-256 | 67ee45cb46b2d772208299e7dcf91df8daab5acfacb6eee44431830fefc05fac |
File details
Details for the file aio_pubsub-0.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: aio_pubsub-0.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | faad5aaa91dd901494f8d575f86cc955dba4b41ad8bdbcafa77955592e5e02d9 |
|
MD5 | 08153505c2e1399428cd2d30cf45ca9f |
|
BLAKE2b-256 | 2a9db6df7fc99c036fcbfa971108984270835fb8f32f14c9497ce8be59ed8700 |