Skip to main content

ApplyContext

Struct ApplyContext 

Source
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>
where S: SurrealSink, T: BatchTransformer + 'static, P: Clone + Send + Sync + 'static,

Source

pub fn new(sink: &'a S, transformer: Arc<T>, opts: &'a ApplyOpts) -> Self

Create an apply context bound to a sink, transformer, and options.

Source

pub fn is_poisoned(&self) -> bool

Whether this context was poisoned by a FailurePolicy::Fail error.

Source

pub fn buffer_len(&self) -> usize

Number of events waiting to form a batch.

Source

pub fn in_flight_count(&self) -> usize

Number of batches currently transforming (JoinSet path).

Source

pub fn sink_in_flight(&self) -> bool

Whether an ordered sink apply is in progress (slot reserved).

Source

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).

Source

pub fn take_sunk_change_count(&mut self) -> u64

Take and reset the count of events sunk since the previous take.

Source

pub fn completed_waiting_count(&self) -> usize

Number of transform results waiting for ordered sink apply.

Source

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.

Source

pub fn is_fully_drained(&self) -> bool

Whether the apply window is fully drained (no unsunk work).

Source

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).

Source

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.

Source

pub async fn push_event( &mut self, event: ApplyEvent, position: P, ) -> Result<Option<P>>

Push a unified positioned event.

Source

pub async fn flush(&mut self) -> Result<Option<P>>

Flush remaining buffered events and wait for in-flight work.

Source

pub async fn write_rows(&self, rows: Vec<Row>) -> Result<()>

Transform then sink rows (same as write_rows_with).

Source

pub async fn write_relations(&self, relations: Vec<Relation>) -> Result<()>

Transform then sink relations (same as write_relations_with).

Auto Trait Implementations§

§

impl<'a, S, T, P> Freeze for ApplyContext<'a, S, T, P>
where P: Freeze,

§

impl<'a, S, T, P> RefUnwindSafe for ApplyContext<'a, S, T, P>

§

impl<'a, S, T, P> Send for ApplyContext<'a, S, T, P>
where S: Sync, T: Sync + Send, P: Send,

§

impl<'a, S, T, P> Sync for ApplyContext<'a, S, T, P>
where S: Sync, T: Sync + Send, P: Sync + Send,

§

impl<'a, S, T, P> Unpin for ApplyContext<'a, S, T, P>
where P: Unpin,

§

impl<'a, S, T, P> UnsafeUnpin for ApplyContext<'a, S, T, P>
where P: UnsafeUnpin,

§

impl<'a, S, T, P> UnwindSafe for ApplyContext<'a, S, T, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more