An event-bus application layer, supports redis
Project description
An event-bus application layer, support redis
Simply ASYNC framework to integrate DISTRIBUTED message bus to your application:
- utilize redis pub/sub features in backend
- fast to start and simply configure
- thread-safe and python async-friendly thanks to coroutines contexts
- fault tolerance if some redis instances down for a little time
- scalable thanks to consistent hashing for mapping
topictoinstancewithout cluster setup
Install
pip install aiobus
Usage
import json
import asyncio
import datetime
from aiobus.redis import RedisBus
...
bus = RedisBus(
servers=['192.168.100.1', '192.168.100.2:6380'],
max_pool_size=1000
)
...
# Publisher Coroutine
async def publisher():
while True:
await bus.publish('my-topic', {'stamp': str(datetime.datetime.now())})
await asyncio.sleep(0.1)
...
# Subscriber Coroutine
async def subscriber():
await bus.subscribe('my-topic')
async for msg in await bus.listen():
print(json.dumps(msg, indent=2, sort_keys=True))
...
Demo
- Setup redis instances on localhost
docker-compose up -dfor demo purposes - Run/Debug Demo script
Running tests
Before to run tests you should
- install dependencies:
pip install -r requirements.txt - start the dependent services with command:
docker-compose up -d
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiobus-1.0.6.tar.gz
(11.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
aiobus-1.0.6-py3-none-any.whl
(11.6 kB
view details)
File details
Details for the file aiobus-1.0.6.tar.gz.
File metadata
- Download URL: aiobus-1.0.6.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f45f323379c57a0a2af5b7a0bdc9e818d872c9798650806e0f801f9bfa149a1a
|
|
| MD5 |
419ea56940134daca97a2ebe398be652
|
|
| BLAKE2b-256 |
6af5bb4ecb92f84a5f6654f18abb39fa6f6bee40bdee5056386dac4badc62ca6
|
File details
Details for the file aiobus-1.0.6-py3-none-any.whl.
File metadata
- Download URL: aiobus-1.0.6-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8759303ecbc6cf27f196fb5d6ebbbd0ad11de90109ff20382372a1c77eb0511e
|
|
| MD5 |
1b5f6d532182e3e66fda09d13aae4ed4
|
|
| BLAKE2b-256 |
005755e2bf627ba885b27cda016d94f4cace5842964519ec9385ccb91cd0a880
|