pub struct TriggerManager { /* private fields */ }Expand description
Business logic layer for the trigger system.
Wraps a dyn TriggerStore and implements condition evaluation,
trigger firing, and execution dedup. Modelled after pynenc’s
BaseTrigger evaluation methods.
Implementations§
Source§impl TriggerManager
impl TriggerManager
pub fn new(store: Arc<dyn TriggerStore>) -> Self
Sourcepub fn store(&self) -> &Arc<dyn TriggerStore>
pub fn store(&self) -> &Arc<dyn TriggerStore>
Access the underlying store (for registration passthrough).
Sourcepub async fn report_status_change(
&self,
ctx: &StatusContext,
) -> RustvelloResult<Vec<ValidCondition>>
pub async fn report_status_change( &self, ctx: &StatusContext, ) -> RustvelloResult<Vec<ValidCondition>>
Report a status change — finds and records matching StatusConditions.
Sourcepub async fn report_result(
&self,
ctx: &ResultContext,
) -> RustvelloResult<Vec<ValidCondition>>
pub async fn report_result( &self, ctx: &ResultContext, ) -> RustvelloResult<Vec<ValidCondition>>
Report a successful task result — finds and records matching ResultConditions.
Sourcepub async fn report_failure(
&self,
ctx: &ExceptionContext,
) -> RustvelloResult<Vec<ValidCondition>>
pub async fn report_failure( &self, ctx: &ExceptionContext, ) -> RustvelloResult<Vec<ValidCondition>>
Report a task failure — finds and records matching ExceptionConditions.
Sourcepub async fn emit_event(
&self,
event_code: &str,
payload: Value,
) -> RustvelloResult<String>
pub async fn emit_event( &self, event_code: &str, payload: Value, ) -> RustvelloResult<String>
Emit a custom event — finds and records matching EventConditions. Returns the generated event ID.
Sourcepub async fn evaluate_cron_conditions(
&self,
) -> RustvelloResult<Vec<ValidCondition>>
pub async fn evaluate_cron_conditions( &self, ) -> RustvelloResult<Vec<ValidCondition>>
Evaluate all cron conditions against the current time.
For each cron condition:
- Parse the
cron_expressionwith thecronercrate; log and skip on syntax error. - Check whether the current minute matches the schedule via
is_time_matched. - Also enforce
min_interval_secondsto prevent double-firing within the same minute. - Use optimistic locking (
store_cron_execution) across multiple runner instances.
Sourcepub async fn evaluate_triggers(
&self,
) -> RustvelloResult<Vec<(TriggerDefinitionDTO, Value)>>
pub async fn evaluate_triggers( &self, ) -> RustvelloResult<Vec<(TriggerDefinitionDTO, Value)>>
Process all pending valid conditions and determine which triggers should fire.
Returns a list of (trigger definition, arguments) pairs ready for invocation.
Trait Implementations§
Source§impl Clone for TriggerManager
impl Clone for TriggerManager
Source§fn clone(&self) -> TriggerManager
fn clone(&self) -> TriggerManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more