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(b"battery.low")
to_control = await control.next_event()
to_logger = await logger.next_event()
print(f"control saw {to_control.decode()}, the logger saw {to_logger.decode()}")
# 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(b"link.up")
first_seen = await late.next_event()
print(f"the late subscriber's first event is {first_seen.decode()}")
# 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(bytes([count]))
resumed = await reader.next_event()
print(f"after five events into a buffer of two, the reader resumes at {resumed[0]}")
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
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 pamoja_bus-0.1.17.tar.gz.
File metadata
- Download URL: pamoja_bus-0.1.17.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9466cc10ef6f87e82fd7bbfa1c91cc81b2467d5298f82d3ca87c315aa0c69493
|
|
| MD5 |
15e62a9e80842bf846079c6c4d04f313
|
|
| BLAKE2b-256 |
fa1d58e450cca7bd8e26b54c153a4cebe7ee1d45d290088c6766625cd063efe2
|
File details
Details for the file pamoja_bus-0.1.17-py3-none-any.whl.
File metadata
- Download URL: pamoja_bus-0.1.17-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92f6b582ada93173956a11a5b731ef041da22b7fd7422d0b92e864baa00de701
|
|
| MD5 |
8a54c489f1139a1c468bc34d0abffbb4
|
|
| BLAKE2b-256 |
4a78f9230ec07830447533e7eb2a0a720057cb14141d39f0bb2b1080b21eb368
|