Skip to main content

Module polling

Module polling 

Source
Expand description

Polling trigger for external data sources.

PollingTrigger periodically executes a PollingProbe and emits a TriggerEvent when the probe detects new data. Optional deduplication prevents re-triggering when the probe result has not changed since the last poll.

§Built-in probes

  • HttpProbe – polls an HTTP endpoint, triggers when the response body changes (behind the trigger-polling-http feature flag).
  • SqlProbe – executes a SQL query, triggers when the result set is non-empty (behind the trigger-polling-sql feature flag).

§Custom probes

Implement PollingProbe to add your own data source:

use ironflow_runtime::trigger::polling::{PollingProbe, ProbeFuture, ProbeResult, ProbeError};

struct MyProbe;

impl PollingProbe for MyProbe {
    fn name(&self) -> &str { "my-probe" }

    fn poll(&self) -> ProbeFuture<'_> {
        Box::pin(async {
            Ok(Some(ProbeResult::new(serde_json::json!({"rows": 42}))))
        })
    }
}

§Examples

use std::time::Duration;
use ironflow_runtime::trigger::polling::{
    PollingTrigger, PollingTriggerConfig, PollingProbe, ProbeFuture, ProbeResult,
    ProbeError,
};

struct StubProbe;
impl PollingProbe for StubProbe {
    fn name(&self) -> &str { "stub" }
    fn poll(&self) -> ProbeFuture<'_> {
        Box::pin(async { Ok(Some(ProbeResult::new(serde_json::json!({"ok": true})))) })
    }
}

let trigger = PollingTrigger::new(PollingTriggerConfig {
    interval: Duration::from_secs(30),
    probe: Box::new(StubProbe),
    workflow_name: "ingest".to_string(),
    dedup: true,
});

Structs§

PollingTrigger
A trigger that periodically polls an external source.
PollingTriggerConfig
Configuration for a PollingTrigger.
ProbeResult
The result of a successful probe execution.

Enums§

ProbeError
Error type for probe operations.

Traits§

PollingProbe
A probe that checks an external data source for new data.

Type Aliases§

ProbeFuture
Future returned by PollingProbe::poll.