pub struct WorkflowGuardConfig {
pub max_depth: u32,
pub max_fan_out: u32,
pub max_workflow_tokens: u64,
pub workflow_timeout_secs: u64,
pub run_deadline: Option<Duration>,
}Expand description
Configurable execution limits for a workflow run.
Each limit has a sensible default. Limits can be set per-handler via
WorkflowHandler::guard_config
or globally on the Engine.
§Examples
use ironflow_engine::guard::WorkflowGuardConfig;
let config = WorkflowGuardConfig::new()
.with_max_depth(3)
.with_max_fan_out(10);
assert_eq!(config.max_depth, 3);
assert_eq!(config.max_fan_out, 10);
assert_eq!(config.max_workflow_tokens, 100_000);Fields§
§max_depth: u32Maximum depth of nested sub-workflows (default 5).
max_fan_out: u32Maximum total number of workflow invocations (default 20).
max_workflow_tokens: u64Cumulative token budget across all agent steps and every execution of the run (default 100,000).
workflow_timeout_secs: u64Global timeout in seconds of active execution time, summed over every execution of the run, sleeping excluded (default 120).
run_deadline: Option<Duration>Absolute deadline of a run, counted from its creation
(Run.created_at), sleeping time included (default None).
Implementations§
Source§impl WorkflowGuardConfig
impl WorkflowGuardConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a configuration with default limits.
§Examples
use ironflow_engine::guard::WorkflowGuardConfig;
assert_eq!(WorkflowGuardConfig::new(), WorkflowGuardConfig::default());Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Load configuration from environment variables.
Reads IRONFLOW_GUARD_MAX_DEPTH, IRONFLOW_GUARD_MAX_FAN_OUT,
IRONFLOW_GUARD_MAX_WORKFLOW_TOKENS, and IRONFLOW_GUARD_WORKFLOW_TIMEOUT_SECS.
Missing or unparseable variables fall back to defaults.
§Examples
use ironflow_engine::guard::WorkflowGuardConfig;
let config = WorkflowGuardConfig::from_env();
// Without env vars set, returns defaults.
assert_eq!(config.max_depth, 5);Sourcepub fn with_max_depth(self, max_depth: u32) -> Self
pub fn with_max_depth(self, max_depth: u32) -> Self
Set the maximum sub-workflow nesting depth.
§Examples
use ironflow_engine::guard::WorkflowGuardConfig;
let config = WorkflowGuardConfig::new().with_max_depth(3);
assert_eq!(config.max_depth, 3);Sourcepub fn with_max_fan_out(self, max_fan_out: u32) -> Self
pub fn with_max_fan_out(self, max_fan_out: u32) -> Self
Set the maximum total workflow invocations.
§Examples
use ironflow_engine::guard::WorkflowGuardConfig;
let config = WorkflowGuardConfig::new().with_max_fan_out(10);
assert_eq!(config.max_fan_out, 10);Sourcepub fn with_max_workflow_tokens(self, max: u64) -> Self
pub fn with_max_workflow_tokens(self, max: u64) -> Self
Set the cumulative token budget.
§Examples
use ironflow_engine::guard::WorkflowGuardConfig;
let config = WorkflowGuardConfig::new().with_max_workflow_tokens(50_000);
assert_eq!(config.max_workflow_tokens, 50_000);Sourcepub fn with_workflow_timeout_secs(self, secs: u64) -> Self
pub fn with_workflow_timeout_secs(self, secs: u64) -> Self
Set the global timeout in seconds.
§Examples
use ironflow_engine::guard::WorkflowGuardConfig;
let config = WorkflowGuardConfig::new().with_workflow_timeout_secs(60);
assert_eq!(config.workflow_timeout_secs, 60);Sourcepub fn with_run_deadline(self, deadline: Duration) -> Self
pub fn with_run_deadline(self, deadline: Duration) -> Self
Set the absolute deadline of a run, counted from its creation.
Unlike the timeout, the deadline includes the time the run spends
sleeping (waiting for an approval, a signal or a timer): a run still
alive deadline after its creation is cancelled.
§Examples
use std::time::Duration;
use ironflow_engine::guard::WorkflowGuardConfig;
let week = Duration::from_secs(7 * 24 * 3600);
let config = WorkflowGuardConfig::new().with_run_deadline(week);
assert_eq!(config.run_deadline, Some(week));Sourcepub fn deadline_for(&self, created_at: DateTime<Utc>) -> Option<DateTime<Utc>>
pub fn deadline_for(&self, created_at: DateTime<Utc>) -> Option<DateTime<Utc>>
The instant a run created at created_at reaches its deadline.
None without run_deadline, or when the
deadline cannot be represented as a date.
§Examples
use std::time::Duration;
use chrono::{TimeDelta, Utc};
use ironflow_engine::guard::WorkflowGuardConfig;
let created_at = Utc::now();
let config = WorkflowGuardConfig::new().with_run_deadline(Duration::from_secs(60));
assert_eq!(
config.deadline_for(created_at),
Some(created_at + TimeDelta::seconds(60))
);
assert_eq!(WorkflowGuardConfig::new().deadline_for(created_at), None);Trait Implementations§
Source§impl Clone for WorkflowGuardConfig
impl Clone for WorkflowGuardConfig
Source§impl Debug for WorkflowGuardConfig
impl Debug for WorkflowGuardConfig
Source§impl Default for WorkflowGuardConfig
impl Default for WorkflowGuardConfig
impl Eq for WorkflowGuardConfig
Source§impl PartialEq for WorkflowGuardConfig
impl PartialEq for WorkflowGuardConfig
impl StructuralPartialEq for WorkflowGuardConfig
Auto Trait Implementations§
impl Freeze for WorkflowGuardConfig
impl RefUnwindSafe for WorkflowGuardConfig
impl Send for WorkflowGuardConfig
impl Sync for WorkflowGuardConfig
impl Unpin for WorkflowGuardConfig
impl UnsafeUnpin for WorkflowGuardConfig
impl UnwindSafe for WorkflowGuardConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.