pub struct ApplyContext<'a, S, T, P = ()> { /* private fields */ }Expand description
Library / custom-loop driver sharing the same ordered apply path as
crate::pipeline::run_source_runtime.
Accepts row Change and RelationChange into one
buffer / window. Identity and non-identity pipelines share one path: every
batch is spawned onto the transform JoinSet (identity is an async
no-op). Sink apply is ordered and may overlap with polling / transforming
later batches; push_* / flush still return Some(position) only after
that batch’s sink succeeds. They do not call
SourceDriver::advance_watermark / ChangeFeed::advance_watermark.
§Poisoning after FailurePolicy::Fail
After a batch fails under FailurePolicy::Fail, this context is
poisoned: successors are discarded, and further push/flush return Err
immediately. Do not reuse — create a new context and replay from the last
successful sink-safe watermark.
Implementations§
Source§impl<'a, S, T, P> ApplyContext<'a, S, T, P>
impl<'a, S, T, P> ApplyContext<'a, S, T, P>
Sourcepub fn new(sink: &'a S, transformer: Arc<T>, opts: &'a ApplyOpts) -> Self
pub fn new(sink: &'a S, transformer: Arc<T>, opts: &'a ApplyOpts) -> Self
Create an apply context bound to a sink, transformer, and options.
Sourcepub fn is_poisoned(&self) -> bool
pub fn is_poisoned(&self) -> bool
Whether this context was poisoned by a FailurePolicy::Fail error.
Sourcepub fn buffer_len(&self) -> usize
pub fn buffer_len(&self) -> usize
Number of events waiting to form a batch.
Sourcepub fn in_flight_count(&self) -> usize
pub fn in_flight_count(&self) -> usize
Number of batches currently transforming (JoinSet path).
Sourcepub fn sink_in_flight(&self) -> bool
pub fn sink_in_flight(&self) -> bool
Whether an ordered sink apply is in progress (slot reserved).
Sourcepub fn window_occupancy(&self) -> usize
pub fn window_occupancy(&self) -> usize
Batches occupying the apply window: transforming + awaiting/in sink.
ApplyOpts::max_in_flight bounds this total so a slow sink back-pressures
new transforms while still allowing overlap (reads / transforms / writes).
Sourcepub fn take_sunk_change_count(&mut self) -> u64
pub fn take_sunk_change_count(&mut self) -> u64
Take and reset the count of events sunk since the previous take.
Sourcepub fn completed_waiting_count(&self) -> usize
pub fn completed_waiting_count(&self) -> usize
Number of transform results waiting for ordered sink apply.
Sourcepub fn has_unsunk_work(&self) -> bool
pub fn has_unsunk_work(&self) -> bool
Whether any buffered, in-flight, completed-waiting, or sinking work remains.
Used by checkpoint policies that must not persist a read-ahead position while transform/apply still has unsunk work.
Sourcepub fn is_fully_drained(&self) -> bool
pub fn is_fully_drained(&self) -> bool
Whether the apply window is fully drained (no unsunk work).
Sourcepub async fn push_change(
&mut self,
change: Change,
position: P,
) -> Result<Option<P>>
pub async fn push_change( &mut self, change: Change, position: P, ) -> Result<Option<P>>
Push one row change; may start transforms and drain ordered sink.
Returns the last position successfully sunk (caller should advance_watermark).
Sourcepub async fn push_relation_change(
&mut self,
change: RelationChange,
position: P,
) -> Result<Option<P>>
pub async fn push_relation_change( &mut self, change: RelationChange, position: P, ) -> Result<Option<P>>
Push one relation change into the same window as row changes.
Sourcepub async fn push_event(
&mut self,
event: ApplyEvent,
position: P,
) -> Result<Option<P>>
pub async fn push_event( &mut self, event: ApplyEvent, position: P, ) -> Result<Option<P>>
Push a unified positioned event.
Sourcepub async fn flush(&mut self) -> Result<Option<P>>
pub async fn flush(&mut self) -> Result<Option<P>>
Flush remaining buffered events and wait for in-flight work.
Sourcepub async fn write_rows(&self, rows: Vec<Row>) -> Result<()>
pub async fn write_rows(&self, rows: Vec<Row>) -> Result<()>
Transform then sink rows (same as write_rows_with).
Sourcepub async fn write_relations(&self, relations: Vec<Relation>) -> Result<()>
pub async fn write_relations(&self, relations: Vec<Relation>) -> Result<()>
Transform then sink relations (same as write_relations_with).