Skip to main content

CreateRunOpts

Struct CreateRunOpts 

Source
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

Source

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");
Source

pub fn trigger(self, trigger: TriggerKind) -> Self

Set how the run was triggered.

Defaults to TriggerKind::Manual if not set.

Source

pub fn payload(self, payload: Value) -> Self

Set the trigger-specific payload.

Defaults to json!({}) if not set.

Source

pub fn max_retries(self, max_retries: u32) -> Self

Set the maximum retry attempts.

Defaults to 0 if not set.

Source

pub fn scheduled_at(self, at: DateTime<Utc>) -> Self

Schedule the run for later execution.

Source

pub fn created_by(self, actor: RunActor) -> Self

Set the authenticated principal creating this run.

Source

pub fn idempotency_key(self, key: impl Into<String>) -> Self

Set an idempotency key to prevent duplicate runs.

Source

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"));
Source

pub fn labels(self, labels: HashMap<String, String>) -> Self

Set user-defined labels for categorization.

Source

pub fn max_cost_usd(self, cap: Decimal) -> Self

Set the maximum cumulative cost allowed for this run.

Source

pub fn worker_tags<I, S>(self, tags: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

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()]);
Source

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.

§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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CreateRunOpts

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CreateRunOpts

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more