Skip to main content

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#.

API reference read the guide documentation

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
TypeScript @pamoja/bus reference
Python pamoja-bus reference
C# Pamoja.Bus reference

Documentation

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

pamoja_bus-0.1.16.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pamoja_bus-0.1.16-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file pamoja_bus-0.1.16.tar.gz.

File metadata

  • Download URL: pamoja_bus-0.1.16.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

Hashes for pamoja_bus-0.1.16.tar.gz
Algorithm Hash digest
SHA256 2bd01a1aa8ee697d69364746daef40ab6a412990f798bdd0de08c8dad8b2366c
MD5 d8d288250f4c031cb1b8855c3c13cb48
BLAKE2b-256 3180fa599bfe29fb99735937117a682b9116c5b8a122f3cbe959ee54fb3d15f5

See more details on using hashes here.

File details

Details for the file pamoja_bus-0.1.16-py3-none-any.whl.

File metadata

  • Download URL: pamoja_bus-0.1.16-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

Hashes for pamoja_bus-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 8e5e940889866af28bdcc34362426067a94914c453fbe3de7ee8d15bb9210503
MD5 4285604f593879d0cad0e0a8c129f5f9
BLAKE2b-256 ca61a498d22bdad21456d9e52a0419bcd555461ea0ad96b24c88bddcb236f66b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.17

2 files

This release

0.1.16 This release

2 files

0.1.15

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page