Skip to main content

Source

Trait Source 

Source
pub trait Source: Send {
    type Lane: SourceLane;

    // Required methods
    fn open(&mut self, ctx: SourceCtx) -> Result<(), SourceError>;
    fn poll_events(
        &mut self,
        timeout: Duration,
    ) -> Result<SourceEvent<Self::Lane>, SourceError>;
    fn commit(
        &mut self,
        watermarks: &[(PartitionId, i64)],
    ) -> Result<(), SourceError>;

    // Provided methods
    fn flush_commits(&mut self) -> Result<(), SourceError> { ... }
    fn pause(&mut self, lanes: &[LaneId]) -> Result<(), SourceError> { ... }
    fn resume(&mut self, lanes: &[LaneId]) -> Result<(), SourceError> { ... }
}
Expand description

Control plane of a source. Driven by the runtime’s controller from a single thread; lanes run on pipeline threads.

Required Associated Types§

Source

type Lane: SourceLane

The lane type this source produces.

Required Methods§

Source

fn open(&mut self, ctx: SourceCtx) -> Result<(), SourceError>

Connect and prepare. Called once before any other method.

Source

fn poll_events( &mut self, timeout: Duration, ) -> Result<SourceEvent<Self::Lane>, SourceError>

Service control-plane work (rebalance callbacks, statistics) and return the next event, waiting at most timeout. Must be called regularly regardless of backpressure state.

Source

fn commit( &mut self, watermarks: &[(PartitionId, i64)], ) -> Result<(), SourceError>

Store per-partition committable positions (each is the offset one past the last acknowledged record). Positions are durable per the source’s own policy (e.g. interval auto-commit of stored offsets).

Provided Methods§

Source

fn flush_commits(&mut self) -> Result<(), SourceError>

Synchronously flush stored positions (shutdown, revocation).

Source

fn pause(&mut self, lanes: &[LaneId]) -> Result<(), SourceError>

Stop fetching for lanes (backpressure). Optional capability: sources that cannot pause rely on bounded-queue pushback alone.

Source

fn resume(&mut self, lanes: &[LaneId]) -> Result<(), SourceError>

Resume fetching for lanes.

Implementations on Foreign Types§

Source§

impl Source for KafkaSource

Source§

type Lane = KafkaLane

Source§

fn open(&mut self, ctx: SourceCtx) -> Result<(), SourceError>

Source§

fn poll_events( &mut self, timeout: Duration, ) -> Result<SourceEvent<KafkaLane>, SourceError>

Source§

fn commit( &mut self, watermarks: &[(PartitionId, i64)], ) -> Result<(), SourceError>

Source§

fn flush_commits(&mut self) -> Result<(), SourceError>

Source§

fn pause(&mut self, lanes: &[LaneId]) -> Result<(), SourceError>

Source§

fn resume(&mut self, lanes: &[LaneId]) -> Result<(), SourceError>

Implementors§