fluxion-ordered-merge
Part of Fluxion - A reactive stream processing library for Rust
Generic ordered stream merging utilities for async Rust.
Overview
This crate provides low-level utilities for merging async streams with temporal ordering guarantees. It works with any stream type implementing the Timestamped trait and serves as a building block for higher-level operators like merge_with in fluxion-stream.
Features
- Generic over any
Timestampedtype - Strict temporal ordering via buffering
- Efficient out-of-order handling
- Zero-copy stream merging where possible
Usage
This crate is primarily used as a building block for higher-level merge operators. Most users should use the merge_with operator from fluxion-stream instead.
Example
use ordered_merge;
use Sequenced;
use Timestamped;
use StreamExt;
async
How It Works
The ordered merge algorithm:
- Polls all input streams concurrently
- Buffers items that arrive out of order
- Emits items strictly by timestamp order
- Handles stream completion correctly
This ensures temporal ordering even when upstream streams emit at different rates or out of sequence.
Performance
- Memory: Buffers only out-of-order items
- Latency: Minimal overhead for in-order streams
- Throughput: Optimized polling and buffering
License
Apache-2.0