Async coordination system using Broker-Emitter-Consumer with testing, we simply call it: "Event Architecture based on Promises"
Project description
Pooter — Async Event Coordination System
Pooter is an asynchronous coordination system built on a simple but powerful pattern:
Emitter → Broker → Consumer
We call this "Event Architecture based on Promises" — where multiple Emitters notify a Broker, which then synchronizes and dispatches events to Consumers once all conditions are fulfilled.
This pattern works on letting an Emitter emits the Broker then the Broker puts all of the other Emitters into the same Promises, which they promise to give give back the same signal (which is emit).
If all resolve, the promising section is finished, otherwise, it's cancelled by the Broker.
✨ Features
- Broker-based event coordination
- Awaitable emit + resolution logic
- Modular
EventBuspub/sub pattern - Fully tested with
pytest-asyncio
📦 Installation
pip install pooter
Or for development:
git clone https://github.com/ticuong78/pooter
cd pooter
pip install -e .[dev]
🚀 Usage Example
# pyright: reportArgumentType=false
import asyncio
import logging
from src.archi.broker import Broker
from src.archi.emitter import Emitter
from src.archi.consumer import Consumer
# Set up logging for visibility
logging.basicConfig(level=logging.INFO)
async def main():
broker = Broker(timeout=1.0)
emitter1 = Emitter()
emitter2 = Emitter()
# decide what the Emitters do on resolve_callback
emitter2.resolve_callback = lambda uuid=emitter2.uuid: print(f"[Emitter {uuid}] internal resolved.")
consumer1 = Consumer()
consumer2 = Consumer()
broker.register_emitter(emitter1)
broker.register_emitter(emitter2)
broker.register_consumer(consumer1)
broker.register_consumer(consumer2)
# Use the awaited API (Option A)
emitter1_task = emitter1.emit() # async def emit()
# Resolve the other emitter after delay
async def delayed():
await asyncio.sleep(0.3)
await emitter2.emit()
await asyncio.gather(delayed(), emitter1_task)
if __name__ == "__main__":
asyncio.run(main())
🧪 Running Tests
pytest tests
Includes:
tests/test_broker.pytests/test_emitter.pytests/test_consumer.pytests/test_events.py
📁 Project Structure
src/
├── archi/
│ ├── broker.py # Orchestrates emitter/consumer coordination
│ ├── emitter.py # Emits to broker
│ ├── consumer.py # Handles post-resolution logic
│ └── events.py # Internal event bus
tests/
└── test_*.py # Full pytest-asyncio test suite
main.py # Example use case
pyproject.toml # Build + metadata
📜 License
MIT License.
Created by Lê Cường — cuongdayne17@gmail.com
🛠️ Contributing
Contributions are welcome and encouraged.
If you'd like to contribute to pooter, please follow these steps:
- Fork the repository
- Create a new branch:
git checkout -b feature/your-feature-name
- Write clear, tested code
- Follow existing code style (
black,ruff,mypy) - Submit a Pull Request with a clear description
Please make sure all tests pass before submitting:
pytest
To run style checks:
black . && ruff . && mypy src/
For ideas, bugs, or PRs, visit: github.com/ticuong78/pooter
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
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
File details
Details for the file pooter-0.2.7.tar.gz.
File metadata
- Download URL: pooter-0.2.7.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efee949ce07e9da8f0ec3c31be25b37b54a0b3fa08263bd64dc35f8bf3f3c799
|
|
| MD5 |
1dada8de78f9b9f796307aa8edca76fe
|
|
| BLAKE2b-256 |
62f7f18bc289b723a94148026f848dcc275d2c0b0547875e0a657650a31aebf7
|
File details
Details for the file pooter-0.2.7-py3-none-any.whl.
File metadata
- Download URL: pooter-0.2.7-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fb94dde1ae58088751cfff40a1e8ce9afdcc19ba29283ba723d43315fa9cc17
|
|
| MD5 |
0d3eb3bd3990e0a594ff09f6b9ac6bfe
|
|
| BLAKE2b-256 |
162d02e61f007af0d295e5afb7d4be22f06ca6b18d1f49694c030f26a7876a35
|