Skip to main content

Listener

Struct Listener 

Source
pub struct Listener<Src, Snk> { /* private fields */ }
Expand description

Watches every table in a MappingSpec and keeps a graph sink current.

Implementations§

Source§

impl<Src: TableSource, Snk: GraphSink> Listener<Src, Snk>

Source

pub fn new( spec: MappingSpec, registry: TransformRegistry, source: Src, sink: Snk, state: SyncState, ) -> Self

Source

pub fn metrics(&self) -> &Metrics

The cumulative run metrics so far (counters folded after every sync_once / poll round). See Metrics and crate::metrics::render_prometheus.

Source

pub fn with_asset_emitter( self, emitter: Arc<dyn AssetEmitter>, uri_prefix: impl Into<String>, ) -> Self

Attach an AssetEmitter: after every successful sync round the listener emits one Airflow asset event per ingested table, with URIs {uri_prefix}{table}. See crate::airflow.

Source

pub async fn sync_once(&mut self) -> Result<RoundReport>

One pass over all mapped tables. A failing table does not stop the others; its state is not advanced, so the next pass retries it.

Source

pub async fn run( &mut self, interval: Duration, on_round: impl FnMut(RoundReport) -> bool, ) -> Result<()>

Poll forever. The sleep between rounds is the base interval on the happy path, but a fully-failed (no-progress) round backs the next sleep off exponentially up to interval * 10 (see Backoff); the first round that makes progress resets it. Errors are carried in the round reports handed to on_round; return false from it to stop.

Signature-compatible with the original fixed-interval run; for a custom cap use run_with_backoff.

Source

pub async fn run_with_backoff( &mut self, backoff: Backoff, on_round: impl FnMut(RoundReport) -> bool, ) -> Result<()>

Poll forever with an explicit Backoff schedule. The happy-path cadence is backoff.interval(); consecutive no-progress rounds grow the inter-round sleep up to backoff.max(), resetting on the first round that makes progress. run is this with a interval … interval*10 default. Return false from on_round to stop.

Auto Trait Implementations§

§

impl<Src, Snk> !RefUnwindSafe for Listener<Src, Snk>

§

impl<Src, Snk> !UnwindSafe for Listener<Src, Snk>

§

impl<Src, Snk> Freeze for Listener<Src, Snk>
where Src: Freeze, Snk: Freeze,

§

impl<Src, Snk> Send for Listener<Src, Snk>
where Src: Send, Snk: Send,

§

impl<Src, Snk> Sync for Listener<Src, Snk>
where Src: Sync, Snk: Sync,

§

impl<Src, Snk> Unpin for Listener<Src, Snk>
where Src: Unpin, Snk: Unpin,

§

impl<Src, Snk> UnsafeUnpin for Listener<Src, Snk>
where Src: UnsafeUnpin, Snk: UnsafeUnpin,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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