Skip to main content

Trigger

Trait Trigger 

Source
pub trait Trigger:
    Send
    + Sync
    + Debug {
    // Required methods
    fn name(&self) -> &str;
    fn poll_interval(&self) -> Duration;
    fn allow_concurrent(&self) -> bool;
    fn poll<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<TriggerResult, TriggerError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn cron_expression(&self) -> Option<String> { ... }
    fn workflow_name(&self) -> &str { ... }
}
Expand description

Core trait for user-defined triggers.

Triggers are polling functions that determine when a workflow should execute. Each trigger has a name, poll interval, and a poll() method that returns whether the workflow should fire.

Required Methods§

Source

fn name(&self) -> &str

Returns the unique name of this trigger.

Source

fn poll_interval(&self) -> Duration

Returns how often this trigger should be polled.

Source

fn allow_concurrent(&self) -> bool

Returns whether concurrent executions with the same context are allowed. When false, if a workflow execution with the same context hash is already running, the trigger will not fire again until it completes.

Source

fn poll<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<TriggerResult, TriggerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Polls the trigger condition and returns whether to fire the workflow.

Called at the configured poll_interval. Returns TriggerResult::Skip to continue polling, TriggerResult::Fire(ctx) to fire the workflow. Errors are logged and polling continues on the next interval.

Provided Methods§

Source

fn cron_expression(&self) -> Option<String>

Returns this trigger’s cron expression, if any. Cron-shaped triggers override this to return Some(expr); their poll_interval is ignored and the reconciler routes them to the cron scheduler instead of the runtime trigger registry. Default None covers all custom-poll triggers.

Source

fn workflow_name(&self) -> &str

The target workflow this trigger fires — the #[trigger(on = "...")] binding. For cron triggers the reconciler registers the schedule against this workflow (not the trigger’s own name). Default empty for manual impls that don’t bind a workflow; macro-generated triggers always override it (CLOACI-T-0669).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§