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 concurrency_key(self, key: impl Into<String>) -> Self
pub fn concurrency_key(self, key: impl Into<String>) -> Self
Set a concurrency key: the store refuses the run while another non-terminal run holds the same key.
§Examples
use ironflow_engine::run_creator::CreateRunOpts;
let new_run = CreateRunOpts::new()
.concurrency_key("issue:12")
.build("deploy", None, None);
assert_eq!(new_run.concurrency_key.as_deref(), Some("issue:12"));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.
Add worker tags the run requires. Extends the tags already set.
Tags are trimmed, sorted and deduplicated by build.
The store refuses invalid ones when the run is created.
§Examples
use ironflow_engine::run_creator::CreateRunOpts;
let new_run = CreateRunOpts::new()
.worker_tags(["region:eu", "gpu"])
.worker_tags(["gpu"])
.build("transcode", None, None);
assert_eq!(new_run.worker_tags, vec!["gpu".to_string(), "region:eu".to_string()]);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)));