Skip to main content

pamoja-loopback

An in-process transport with topic matching and a fault injector, for testing with no broker. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.

read the guide documentation API reference

Install

pip install pamoja-loopback
from pamoja import loopback

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/loopback.py:

import asyncio

from pamoja.core import PamojaError
from pamoja.loopback import LoopbackBroker


async def main() -> None:
    # One broker and two links off it, all in this process. Nothing binds a port and
    # nothing has to be running for the traffic below to flow, which is what makes this
    # the link to develop a node against before it has a real one.
    broker = LoopbackBroker()
    publisher = broker.link()
    subscriber = broker.link()
    await publisher.connect()
    await subscriber.connect()

    # A `+` stands for exactly one level, so this takes the mixer's temperature but not the
    # raw reading a level below it.
    await subscriber.subscribe("line/+/temp")
    await publisher.send("line/mixer/temp/raw", "2150")
    await publisher.send("line/mixer/temp", "21.5")

    message = await subscriber.recv()
    print(f"line/+/temp took {message.text} from {message.topic}")

    # A `#` covers every level that remains, so a second link takes the whole subtree,
    # including the reading the single-level filter passed over.
    watcher = broker.link()
    await watcher.connect()
    await watcher.subscribe("line/#")
    await publisher.send("line/mixer/temp/raw", "2150")

    deep = await watcher.recv()
    print(f"line/#     took {deep.text} from {deep.topic}")

    # A link that has been disconnected reports the failure instead of dropping the
    # reading, which is the case a test wants to reach without unplugging anything.
    await publisher.disconnect()
    try:
        await publisher.send("line/mixer/temp", "21.6")
        print("a disconnected link took a reading, which should never happen")
    except PamojaError as error:
        print(f"disconnected refused the reading: {error}")

    return message, deep


message, deep = asyncio.run(main())

The same capability in every language

Language Package Reference
Rust pamoja-loopback reference, docs.rs, install
TypeScript @pamoja/loopback reference, install
Python pamoja-loopback reference, install
C# Pamoja.Loopback reference, install

Documentation

License

MIT

Release files for pamoja-loopback 0.1.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pamoja-loopback 0.1.18
File Size Uploaded
pamoja_loopback-0.1.18.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pamoja-loopback 0.1.18
File Interpreter ABI Platform
pamoja_loopback-0.1.18-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / pamoja_loopback-0.1.18.tar.gz

Download URL pamoja_loopback-0.1.18.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
17d809cf8417821dc31f3aee3aad1b9f1f0fa2570f614b26e170a7c89ec5c11e
BLAKE2b-256 checksum
How to use checksums
bc383ff2a89dac6ea23dc4fb4770193873cf1c2715dc004b585d6e5a9faa3629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / pamoja_loopback-0.1.18-py3-none-any.whl

Download URL pamoja_loopback-0.1.18-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58d3ede4b0c0b1d7bdbf8a1fdd7ac194f5a725897c4dbe67fb6e62b70fb9f211
BLAKE2b-256 checksum
How to use checksums
d1bb14b5415a8f7c07c0950bd818c1bf46d6589efc098f70a527e0ce292db5c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.18 This release

2 release 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