pub struct CreateRunOpts { /* private fields */ }Expand description
Builder for optional run creation fields.
Builds a NewRun from handler metadata plus user-supplied overrides.
Use with WorkflowHandler::create_run to avoid duplicating workflow
name, version, and cost cap at every call site.
§Examples
use ironflow_engine::run_creator::CreateRunOpts;
use ironflow_store::entities::TriggerKind;
use serde_json::json;
let new_run = CreateRunOpts::new()
.trigger(TriggerKind::Webhook { path: "/hooks/gh".to_string() })
.payload(json!({"ref": "main"}))
.max_retries(3)
.build("deploy", Some("2.0.0"), None);
assert_eq!(new_run.workflow_name, "deploy");
assert_eq!(new_run.max_retries, 3);
assert_eq!(new_run.handler_version, Some("2.0.0".to_string()));Implementations§
Source§impl CreateRunOpts
impl CreateRunOpts
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder with all fields unset.
§Examples
use ironflow_engine::run_creator::CreateRunOpts;
let opts = CreateRunOpts::new();
let new_run = opts.build("my-workflow", None, None);
assert_eq!(new_run.workflow_name, "my-workflow");Sourcepub fn trigger(self, trigger: TriggerKind) -> Self
pub fn trigger(self, trigger: TriggerKind) -> Self
Set how the run was triggered.
Defaults to TriggerKind::Manual if not set.
Sourcepub fn payload(self, payload: Value) -> Self
pub fn payload(self, payload: Value) -> Self
Set the trigger-specific payload.
Defaults to json!({}) if not set.
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
Set the maximum retry attempts.
Defaults to 0 if not set.
Sourcepub fn scheduled_at(self, at: DateTime<Utc>) -> Self
pub fn scheduled_at(self, at: DateTime<Utc>) -> Self
Schedule the run for later execution.
Sourcepub fn created_by(self, actor: RunActor) -> Self
pub fn created_by(self, actor: RunActor) -> Self
Set the authenticated principal creating this run.
Sourcepub fn idempotency_key(self, key: impl Into<String>) -> Self
pub fn idempotency_key(self, key: impl Into<String>) -> Self
Set an idempotency key to prevent duplicate runs.
Sourcepub fn labels(self, labels: HashMap<String, String>) -> Self
pub fn labels(self, labels: HashMap<String, String>) -> Self
Set user-defined labels for categorization.
Sourcepub fn max_cost_usd(self, cap: Decimal) -> Self
pub fn max_cost_usd(self, cap: Decimal) -> Self
Set the maximum cumulative cost allowed for this run.
Sourcepub fn build(
self,
workflow_name: &str,
handler_version: Option<&str>,
default_max_cost_usd: Option<Decimal>,
) -> NewRun
pub fn build( self, workflow_name: &str, handler_version: Option<&str>, default_max_cost_usd: Option<Decimal>, ) -> NewRun
Assemble a NewRun from these options and handler metadata.
workflow_name– typically fromWorkflowHandler::name.handler_version– typically fromWorkflowHandler::version.default_max_cost_usd– typically fromWorkflowHandler::default_max_cost_usd. Applied only whenmax_cost_usdwas not set.
§Examples
use ironflow_engine::run_creator::CreateRunOpts;
use rust_decimal::Decimal;
let new_run = CreateRunOpts::new()
.build("my-handler", Some("3.0.0"), Some(Decimal::new(1000, 2)));
assert_eq!(new_run.workflow_name, "my-handler");
assert_eq!(new_run.handler_version, Some("3.0.0".to_string()));
assert_eq!(new_run.max_cost_usd, Some(Decimal::new(1000, 2)));Trait Implementations§
Source§impl Clone for CreateRunOpts
impl Clone for CreateRunOpts
Source§fn clone(&self) -> CreateRunOpts
fn clone(&self) -> CreateRunOpts
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more