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>
impl<Src: TableSource, Snk: GraphSink> Listener<Src, Snk>
pub fn new( spec: MappingSpec, registry: TransformRegistry, source: Src, sink: Snk, state: SyncState, ) -> Self
Sourcepub fn metrics(&self) -> &Metrics
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.
Sourcepub fn with_asset_emitter(
self,
emitter: Arc<dyn AssetEmitter>,
uri_prefix: impl Into<String>,
) -> Self
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.
Sourcepub async fn sync_once(&mut self) -> Result<RoundReport>
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.
Sourcepub async fn run(
&mut self,
interval: Duration,
on_round: impl FnMut(RoundReport) -> bool,
) -> Result<()>
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.
Sourcepub async fn run_with_backoff(
&mut self,
backoff: Backoff,
on_round: impl FnMut(RoundReport) -> bool,
) -> Result<()>
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>
impl<Src, Snk> Send for Listener<Src, Snk>
impl<Src, Snk> Sync for Listener<Src, Snk>
impl<Src, Snk> Unpin for Listener<Src, Snk>
impl<Src, Snk> UnsafeUnpin for Listener<Src, Snk>where
Src: UnsafeUnpin,
Snk: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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