Expand description
Cost-aware transport ladder for the pamoja SDK.
A field node usually has more than one way to reach the wider network, and
those links differ wildly in cost, range, and availability: a local mesh hop is
nearly free, long-range radio is cheap but slow, cellular is metered, and
satellite is expensive. TransportLadder models that hierarchy. It holds a
set of Transport rungs ordered cheapest-first and,
on each send, uses the first rung that accepts the message. When no rung is
reachable, the message is buffered in a durable Store
and replayed later, so connectivity degrades gracefully instead of failing.
This is the offline-first behavior the target deployments need on day one: an irrigation node or a fridge alarm keeps recording while every link is down and loses nothing once one returns.
§Ordering and the buffer
Delivery is in order. Once anything is buffered, later sends are buffered too
rather than jumping ahead of the backlog over a recovered link;
flush drains the backlog oldest-first, removing each
record only after a rung accepts it. The pattern is to call
flush when a link event suggests connectivity may
have returned, and send for new data.
§Examples
use pamoja_ladder::{Delivery, TransportLadder};
use pamoja_loopback::{LoopbackBroker, LoopbackTransport};
use pamoja_sync::MemoryStore;
let broker = LoopbackBroker::new();
let mut ladder =
TransportLadder::new(MemoryStore::new()).rung(LoopbackTransport::new(broker.clone()));
ladder.connect().await?;
match ladder.send("sensors/1/temperature", b"21.5").await? {
Delivery::Sent => println!("delivered over a live link"),
Delivery::Buffered => println!("no link, buffered for later"),
}Structs§
- Transport
Ladder - An ordered set of transports backed by an offline buffer.
Enums§
- Delivery
- The outcome of a
TransportLadder::send.