Code Examples
Working examples that demonstrate each IndexBus execution pattern.
Minimal Fanout Pipeline
The simplest IndexBus pipeline: one producer, one router, one consumer. The producer publishes 10,000 typed messages through a work-queue router, and the consumer drains them.
Run: cargo run -p indexbus --example p0_routing_lane_minimal
Edge Gateway Pipeline
A two-stage pipeline demonstrating multi-region fanout. Raw frames are ingested, distributed to decode workers via a work-queue router, then decoded messages are broadcast to sink consumers.
- Raw region: SPSC producer → WorkQueue router → N decode workers.
- Decoded region: Workers publish via MPSC → Broadcast router → N sink consumers.
- Message types:
RawFrame { seq: u64, adc: u16 }→Decoded { seq: u64, milli_units: i32 }
Run: cargo run -p indexbus --example p0_edge_gateway_minimal
Full source: crates/indexbus/examples/p0_edge_gateway_minimal.rs (~220 lines)
Sequencer (Disruptor-Style Coordination)
Monotonic sequence claiming with per-consumer gating. The producer claims sequence numbers, publishes, and advances the cursor. The consumer waits on each sequence via a barrier and advances its gating position.
Run: cargo run -p indexbus --example p1_sequencer_minimal --release
Journal (Append-Only Log with Tail/Replay)
Append 10 log records and tail them as they appear. The publisher writes to a segmented journal region, and the subscriber polls for new records.
Run: cargo run -p indexbus --example p1_journal_minimal