pub struct PollingTrigger { /* private fields */ }Expand description
A trigger that periodically polls an external source.
See the module-level documentation for usage examples.
§Examples
use std::time::Duration;
use ironflow_runtime::trigger::polling::{
PollingTrigger, PollingTriggerConfig, PollingProbe, ProbeFuture, ProbeResult,
};
struct Stub;
impl PollingProbe for Stub {
fn name(&self) -> &str { "stub" }
fn poll(&self) -> ProbeFuture<'_> {
Box::pin(async { Ok(Some(ProbeResult::new(serde_json::json!(null)))) })
}
}
let trigger = PollingTrigger::new(PollingTriggerConfig {
interval: Duration::from_secs(30),
probe: Box::new(Stub),
workflow_name: "ingest".to_string(),
dedup: false,
});Implementations§
Source§impl PollingTrigger
impl PollingTrigger
Sourcepub fn new(config: PollingTriggerConfig) -> Self
pub fn new(config: PollingTriggerConfig) -> Self
Create a new polling trigger.
§Examples
use std::time::Duration;
use ironflow_runtime::trigger::polling::{
PollingTrigger, PollingTriggerConfig, PollingProbe, ProbeFuture, ProbeResult,
};
struct Stub;
impl PollingProbe for Stub {
fn name(&self) -> &str { "stub" }
fn poll(&self) -> ProbeFuture<'_> {
Box::pin(async { Ok(Some(ProbeResult::new(serde_json::json!(null)))) })
}
}
let trigger = PollingTrigger::new(PollingTriggerConfig {
interval: Duration::from_secs(10),
probe: Box::new(Stub),
workflow_name: "check".to_string(),
dedup: true,
});Trait Implementations§
Source§impl Trigger for PollingTrigger
impl Trigger for PollingTrigger
Source§fn start<'a>(
&'a self,
sink: TriggerSink,
token: &'a CancellationToken,
) -> TriggerFuture<'a>
fn start<'a>( &'a self, sink: TriggerSink, token: &'a CancellationToken, ) -> TriggerFuture<'a>
Start the trigger. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for PollingTrigger
impl !UnwindSafe for PollingTrigger
impl Freeze for PollingTrigger
impl Send for PollingTrigger
impl Sync for PollingTrigger
impl Unpin for PollingTrigger
impl UnsafeUnpin for PollingTrigger
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
Mutably borrows from an owned value. Read more