pamoja-bus
An in-memory typed publish and subscribe event bus. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
pip install pamoja-bus
from pamoja import bus
This pulls in pamoja-native, the compiled engine. pip install pamoja is the whole framework in one package.
Example
The script the test suite runs, spliced here as it ran.
From bindings/python/guides/bus.py:
import asyncio
from pamoja.bus import EventBus
async def main() -> None:
# A sampler announces something and whatever cares picks it up, with neither side
# holding a reference to the other. This is how the parts of one node are wired.
hub = EventBus(8)
control = await hub.subscribe()
logger = await hub.subscribe()
await hub.publish("battery.low")
to_control = await control.next_text()
to_logger = await logger.next_text()
print(f"control saw {to_control}, the logger saw {to_logger}")
# A subscriber taken later starts from the next event, so it never sees what went out
# before it existed.
late = await hub.subscribe()
await hub.publish("link.up")
first_seen = await late.next_text()
print(f"the late subscriber's first event is {first_seen}")
# The buffer is per subscriber and bounded, so one further behind than the capacity
# drops what it missed and resumes with the most recent events. A slow reader costs
# itself, not the publisher.
slow = EventBus(2)
reader = await slow.subscribe()
for count in range(5):
await slow.publish(str(count))
resumed = await reader.next_text()
print(f"after five events into a buffer of two, the reader resumes at {resumed}")
return to_control, to_logger, first_seen, resumed
to_control, to_logger, first_seen, resumed = asyncio.run(main())
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-bus |
reference, docs.rs, install |
| TypeScript | @pamoja/bus |
reference, install |
| Python | pamoja-bus |
reference, install |
| C# | Pamoja.Bus |
reference, install |
Documentation
pamoja.busreference, every class and function in this module.- The Event bus guide, with the same example in Rust, TypeScript, and C#.
- Every capability, and the install page.
License
MIT
Release files for pamoja-bus 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pamoja_bus-0.1.18.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_bus-0.1.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / pamoja_bus-0.1.18.tar.gz
| Download URL | pamoja_bus-0.1.18.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aca3822df34f47348862236b856a8c7cb2e810f4477142a445b2e28bee4df55a
|
|
BLAKE2b-256 checksum How to use checksums |
7f9bfc6ca6eb8368f8ef915d9d0666a7e02a45b43dc914ab37442e41c42fbb50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pamoja_bus-0.1.18-py3-none-any.whl
| Download URL | pamoja_bus-0.1.18-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1e7dd61d6d31fa83098932c37cbd9b8576f90f64ba514c625e3b6853c9618d1
|
|
BLAKE2b-256 checksum How to use checksums |
c8b5837026b1ad6411540854db93ab3d1e3f739313a035850487885723dc256b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|