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

API reference read the guide documentation

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", b"2150")
    await publisher.send("line/mixer/temp", b"21.5")

    message = await subscriber.recv()
    print(f"line/+/temp took {message.payload.decode()} 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", b"2150")

    deep = await watcher.recv()
    print(f"line/#     took {deep.payload.decode()} 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", b"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.17

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.17
File Size Uploaded
pamoja_loopback-0.1.17.tar.gz 3.3 kB Details

Built distribution (wheel)

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

Total release size: 7.3 kB

Release files / pamoja_loopback-0.1.17.tar.gz

Download URL pamoja_loopback-0.1.17.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b1e2fe843cd91d70001dea025764e568e08a803a42ccf882dcbd8c5a6fc5490c
BLAKE2b-256 checksum
How to use checksums
b7a6af1aa6010b263188dc4f1958faa9050fe40e017ca4ff2e6898f05af050b6
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.17-py3-none-any.whl

Download URL pamoja_loopback-0.1.17-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68c109d15b820b149e5294bc2e63a2add19842dc2bc7da18afb40011fadf464a
BLAKE2b-256 checksum
How to use checksums
364dd01896bbb9f269d91165ea9c1fb9d1f4f473fa0f4b5665ddcf403830dc2a
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

0.1.18

2 release files

This release

0.1.17 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