pub struct TriggerContext {
pub labels: HashMap<String, String>,
pub error: Option<String>,
pub cost_usd: Decimal,
pub duration_ms: u64,
}Expand description
Context available to TriggerConditions when evaluating whether a
rule should fire.
Exposes metadata from the source run: labels, error message, aggregated cost and duration.
§Examples
use std::collections::HashMap;
use ironflow_runtime::trigger::event::TriggerContext;
use rust_decimal::Decimal;
let ctx = TriggerContext {
labels: HashMap::from([("env".to_string(), "prod".to_string())]),
error: Some("timeout".to_string()),
cost_usd: Decimal::new(42, 2),
duration_ms: 5000,
};
assert_eq!(ctx.labels.get("env").unwrap(), "prod");Fields§
§labels: HashMap<String, String>Labels of the source run.
error: Option<String>Error message of the source run (if any).
cost_usd: DecimalAggregated cost in USD of the source run.
duration_ms: u64Aggregated duration in milliseconds of the source run.
Trait Implementations§
Source§impl Clone for TriggerContext
impl Clone for TriggerContext
Source§fn clone(&self) -> TriggerContext
fn clone(&self) -> TriggerContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TriggerContext
impl RefUnwindSafe for TriggerContext
impl Send for TriggerContext
impl Sync for TriggerContext
impl Unpin for TriggerContext
impl UnsafeUnpin for TriggerContext
impl UnwindSafe for TriggerContext
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