moonpool-transport

Crates.iomoonpool-transport
lib.rsmoonpool-transport
version0.3.0
created_at2025-12-03 17:03:46.426638+00
updated_at2026-01-25 12:47:05.747118+00
descriptionFDB-style transport layer for the moonpool framework
homepage
repositoryhttps://github.com/PierreZ/moonpool
max_upload_size
id1964579
size430,780
Pierre Zemb (PierreZ)

documentation

https://docs.rs/moonpool-transport

README

moonpool-transport

FDB-style transport layer for the moonpool simulation framework.

Why: Same Code, Different Environments

Networking primitives that work identically in simulation and production. Your application code doesn't change—only the provider implementation does.

This follows FoundationDB's FlowTransport patterns, where the same fdbserver code runs in both real deployments and the simulator.

How: Provider Swapping

The transport layer depends on NetworkProvider and TimeProvider traits from moonpool-core:

Environment NetworkProvider TimeProvider
Production TokioNetworkProvider TokioTimeProvider
Simulation SimNetworkProvider SimTimeProvider

Build your transport once with provider traits. In production, inject tokio-based providers for real TCP. In simulation, inject sim providers that route through the deterministic event loop.

RPC Semantics

Request/Response with Correlation: Every request gets a unique correlation ID. Responses are routed back to the correct waiting caller.

Automatic Reconnection: When connections drop, peers reconnect with exponential backoff. Messages queue during disconnection and drain when connectivity returns.

Message Queuing: The transport buffers outbound messages during network failures rather than failing immediately. This matches real-world patterns where brief outages shouldn't cause application errors.

Wire Format

  • Length-prefixed packets for framing
  • CRC32C checksums for integrity
  • Corruption detection triggers reconnection rather than silent failures

Architecture

┌─────────────────────────────────────────────────┐
│              Application Code                    │
│         Uses NetTransport + RPC                  │
├─────────────────────────────────────────────────┤
│     NetTransport (endpoint routing)             │
│     • Multiplexes connections per endpoint      │
│     • Request/response with correlation         │
├─────────────────────────────────────────────────┤
│     Peer (connection management)                │
│     • Automatic reconnection with backoff       │
│     • Message queuing during disconnection      │
├─────────────────────────────────────────────────┤
│     Wire Format (serialization)                 │
│     • Length-prefixed packets                   │
│     • CRC32C checksums                          │
└─────────────────────────────────────────────────┘

Documentation

License

Apache 2.0

Commit count: 197

cargo fmt