Expand description
Operator chain: statically composed push stages behind one type-erasure boundary per batch.
Stages compose via Collector (monomorphized — a whole chain compiles
to one loop); the only virtual call on the data path is
RunnableChain::push_batch, once per poll batch. Records are born
(deserialized) and die (encoded into shard frames, filtered, or skipped)
inside a single push_batch call, so borrowed payloads never cross or
outlive the boundary. See docs/DESIGN.md (§ Frozen v1 contracts).
Structs§
- Chain
Builder - Fluent builder for one pipeline’s operator chain.
DFis the deserializer’s record family;CurFthe family at the current end of the chain (changed bymap_recandflat_map, and bymapfor owned payloads). - Chain
Factory - Stamps out identical chains — one per pipeline thread.
Send + Syncwhen the deserializer, stage closures, encoder, and router are. - Chunk
Config - Tuning for the terminal stage’s per-shard chunking.
- Emitter
- Stack-borrowed emitter handed to
flat_mapclosures. Parameterized by the output family (a'statictag), so user closures never name the concrete downstream stack type or the buffer lifetime. Eachemitis one virtual call — confined to flat_map stages. - Filter
filter: drop records failing the predicate. A drop releases the record’s ack share — it counts as success for the batch.- Filter
Part - Recorded
filterstage. - FlatMap
flat_map: one record in, 0..N out via a stack-borrowedEmitter. Carries the output family as a type parameter so the impl is fully constrained (closure argument types are not associated bindings).- Flat
MapPart - Recorded
flat_mapstage. - Inspect
inspect: observe without transforming (no metrics of its own).- Inspect
Part - Recorded
inspectstage. - Map
map: transform the payload.- MapPart
- Recorded
map/map_recstage. - Root
- The empty stage list.
- Sink
Handoff - The chain’s terminal stage. Owns one accumulation buffer per shard,
seals
EncodedChunks atChunkConfig::target_bytes, and hands them to the sink workers through the boundedShardQueues— atry_sendthat never blocks the pipeline thread. - Sinked
Chain - A fully specified chain, ready to build — or to stamp out one instance
per pipeline thread via
SinkedChain::build_factory. - TryMap
try_map: fallible transform with a per-stageErrorPolicy.Skipdrops the record (releasing its ack share) and counts it;Failrecords a fatal error — the batch aborts and the pipeline stops.- TryMap
Part - Recorded
try_map/try_map_recstage. - Typed
Chain - A concrete chain: deserializer + statically composed operator stack,
erased behind
RunnableChain.Opsmust accept the family’s record type at every buffer lifetime — the HRTB is what makes borrowed records legal behind the erased boundary.
Enums§
- Block
Reason - Why a batch could not complete yet. Both cases are retried with the
resume cursor, but only
BlockReason::Capacityengages the driver’s backpressure controller — a not-ready wait is an upstream dependency (e.g. a schema fetch), not sink pressure, and pausing the source for it would misreport the pipeline’s state. - Push
Outcome - Result of pushing one batch (or a resumed suffix of one) through a chain.
Traits§
- Assemble
- Assembles recorded parts into the concrete collector stack, given the
terminal stage. Takes
&selfso one set of parts can assemble many identical chains — stage closures must beClone(plain closures and closures overClone/Arcstate are). - Collector
- Push-model stage: receives one record, forwards 0..N downstream.
- Collector
For - Family-erased collector: accepts the family’s record type at any
buffer lifetime through a lifetime-generic method, which keeps it
dyn-compatible. This is what lets
flat_mapclosures hold a plain&mut Emitter<'_, OutF>without naming the downstream stack type. - Runnable
Chain - THE SEAM — the one erasure boundary between a pipeline thread’s driver
loop and a typed chain. The methods are generic over the buffer lifetime
only, so
Box<dyn RunnableChain>is legal. - Stage
Lifecycle - Per-batch lifecycle cascade implemented by every stage. Combinators handle their own concern and delegate downstream; the terminal stage anchors the recursion.
Functions§
- chain
- Start a chain from a deserializer producing family
F. - chain_
owned - Start a chain from a deserializer producing owned records
T.