Skip to main content

SourceLane

Trait SourceLane 

Source
pub trait SourceLane: Send {
    type Batch<'a>: PayloadBatch<'a>
       where Self: 'a;

    // Required methods
    fn id(&self) -> LaneId;
    fn partition(&self) -> PartitionId;
    fn poll(
        &mut self,
        max_records: usize,
        timeout: Duration,
    ) -> Result<Option<Self::Batch<'_>>, SourceError>;

    // Provided method
    fn finished(&self) -> bool { ... }
}
Expand description

Data-plane pollable unit of a source, owned by one pipeline thread.

Contract: payloads yielded by SourceLane::poll are valid only until the returned batch is dropped, which happens before the next poll call on the same lane. Records must be consumed or encoded within that window (the operator chain guarantees this by construction).

Required Associated Types§

Source

type Batch<'a>: PayloadBatch<'a> where Self: 'a

The borrowed batch type (a GAT so payloads can borrow lane buffers).

Required Methods§

Source

fn id(&self) -> LaneId

This lane’s identity within the current assignment.

Source

fn partition(&self) -> PartitionId

The source partition this lane reads. Used for checkpoint issuing and shard routing fallback.

Source

fn poll( &mut self, max_records: usize, timeout: Duration, ) -> Result<Option<Self::Batch<'_>>, SourceError>

Poll up to max_records payloads, waiting at most timeout. Ok(None) means nothing arrived; the driver treats it as idle. Implementations must not busy-spin when idle; block up to timeout. A lane that reports finished may return its end-of-input Ok(None) without waiting out timeout, because the pipeline thread stops polling it.

Provided Methods§

Source

fn finished(&self) -> bool

Whether this lane has reached the end of its input and will not be polled again.

It may turn true only after a poll on this lane returned the Ok(None) that decided its end-of-input, with no batch left to emit, the rule SourceEvent::Drained states. A lane that reports true while it still holds data has that data never read. Once true, it stays true for the life of the lane.

The pipeline thread reads it before every poll and does not poll a lane that reports true; the lane still receives its stop, drop and shutdown. It is read on every turn, so it must be a cheap read that does no I/O and never blocks. The default false keeps the lane polled.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§