Skip to main content

pamoja-ladder

Cheapest reachable link first, buffering to a store when every link is down. 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-ladder
from pamoja import ladder

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

import asyncio

from pamoja.core import Transport
from pamoja.ladder import Delivery, Ladder
from pamoja.loopback import LoopbackBroker
from pamoja.sync import Store

TOPIC = "sensors/1/temperature"


async def main() -> None:
    # Two links off the same node: a near mesh hop and a metered backhaul. Each has its
    # own broker, so which rung carried a reading is visible from its subscriber.
    mesh = LoopbackBroker()
    backhaul = LoopbackBroker()
    gateway = backhaul.link()
    await gateway.connect()
    await gateway.subscribe(TOPIC)

    # Rungs are tried in the order they are added, cheapest first. The mesh hop loses
    # every packet here; the backhaul carries one send, then drops the next two.
    ladder = Ladder(Store.memory())
    await ladder.rung(Transport.degraded(mesh.rung(), drop_every=1))
    await ladder.rung(Transport.degraded(backhaul.rung(), up=1, down=2))
    await ladder.connect()

    # The mesh hop refuses, so the reading goes out over the backhaul and arrives on the
    # broker only that rung publishes to.
    first = await ladder.send(TOPIC, b"21.5")
    arrived = await gateway.recv()
    print(f"first reading: {first}, gateway got {arrived.payload.decode()}")

    # Now nothing will take a send, so the next reading is buffered rather than lost.
    second = await ladder.send(TOPIC, b"21.6")
    waiting = await ladder.buffered()
    print(f"second reading: {second}, {waiting} waiting in the queue")

    # A flush while the links are still down forwards nothing and leaves the backlog
    # intact, because a record is removed only once a rung has accepted it.
    while_down = await ladder.flush()
    print(f"flush while down forwarded {while_down}, queue still {await ladder.buffered()}")

    # The backhaul is reachable again, so the buffered reading goes out exactly once.
    when_up = await ladder.flush()
    late = await gateway.recv()
    print(f"flush when up forwarded {when_up}, gateway got {late.payload.decode()}")

    return first, second, waiting, while_down, when_up, await ladder.buffered(), late


first, second, waiting, while_down, when_up, left, late = asyncio.run(main())

The same capability in every language

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

Documentation

License

MIT

Release files for pamoja-ladder 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-ladder 0.1.17
File Size Uploaded
pamoja_ladder-0.1.17.tar.gz 3.6 kB Details

Built distribution (wheel)

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

Total release size: 7.8 kB

Release files / pamoja_ladder-0.1.17.tar.gz

Download URL pamoja_ladder-0.1.17.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9e735494ff276608a88b36a75d7ab2089bdcacc6d66ba60446b40b3d7ec8f441
BLAKE2b-256 checksum
How to use checksums
e238b0e7be0f8d2dc4ce3be812adff2b586fd6fe2b4c71a4ddd9f83d7d65b33e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / pamoja_ladder-0.1.17-py3-none-any.whl

Download URL pamoja_ladder-0.1.17-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84d12e9dfef44d1841abd7dd6e398b1573b994df6a5748444e001fdc259c6b36
BLAKE2b-256 checksum
How to use checksums
8b9a41222c09b1fb6d3ea8079cf60fdf1438dd1128c3be00189f698c112c2ea8
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