Skip to main content

RunState

Struct RunState 

Source
pub struct RunState {
Show 27 fields pub break_before: Option<String>, pub id: String, pub workflow: String, pub workflow_hash: String, pub inputs: Value, pub status: RunStatus, pub start: Start, pub steps: BTreeMap<String, StepState>, pub vars: Map<String, Value>, pub tokens: u64, pub steps_run: u32, pub output: Option<Value>, pub error: Option<String>, pub task: Option<String>, pub principal: Option<String>, pub conversation: Option<String>, pub children: Vec<String>, pub parent: Option<Value>, pub msg_depth: u32, pub key: Option<String>, pub attempt: u32, pub created: u64, pub updated: u64, pub finished: Option<u64>, pub deadline_ms: Option<u64>, pub durable: bool, pub dirty: bool,
}
Expand description

The durable run record: the whole state of one run, and the only thing that has to survive a restart for the scheduler to carry on where it stopped.

Fields§

§break_before: Option<String>

Stop this run just before the named step starts (a breakpoint set with workflow.pause {before_step}). Durable, so it survives a restart — which is the point: the interesting bugs are the ones that need one.

§id: String§workflow: String§workflow_hash: String§inputs: Value§status: RunStatus§start: Start§steps: BTreeMap<String, StepState>§vars: Map<String, Value>§tokens: u64§steps_run: u32§output: Option<Value>§error: Option<String>§task: Option<String>§principal: Option<String>§conversation: Option<String>§children: Vec<String>§parent: Option<Value>§msg_depth: u32

How many message hops caused this run, counted from the last trigger that was not itself a delivered message. A run started by a schedule, webhook or stream is depth 0; one started by an agent that a message woke inherits that message’s depth. message refuses past limits.max_message_depth, which is what stops message → turn → run → message from re-arming itself forever. Volume alone cannot be the test: twenty unrelated workflows greeting the operator are not a loop, and one workflow greeting itself is.

§key: Option<String>

The logical thing this run is about (the workflow’s key:, rendered against the trigger payload). Durable, so a restart still knows which runs are about the same entity.

§attempt: u32§created: u64§updated: u64§finished: Option<u64>§deadline_ms: Option<u64>§durable: bool

Durability class, resolved at creation from the workflow (default true). false ⇒ this run is memory-only: the checkpoint skips it and a restart forgets it — the fast path for recomputable work. Restored records (all durable by construction) default true.

§dirty: bool

Implementations§

Source§

impl RunState

Source

pub fn new(id: &str, wf: &Workflow, start: Start, inputs: Value) -> RunState

Source

pub fn touch(&mut self)

Source

pub fn step(&self, id: &str) -> Option<&StepState>

Source

pub fn data(&self, env: Value, memory: Value) -> Data

The template data view of this run: the root names {{…}} and CEL expressions may reference. memory and env are supplied by the caller rather than read here, because env must be curated and secret-free before a template can see it.

Source

pub fn begin_step(&mut self, id: &str) -> u32

Mark a step running (attempt +1). Returns the attempt.

Source

pub fn end_step( &mut self, id: &str, status: StepStatus, output: Option<Value>, error: Option<String>, )

Record a step’s terminal outcome.

Source

pub fn suspend_step(&mut self, id: &str, wait: Value)

Record a suspension (timer/gate/budget).

Source

pub fn finish( &mut self, status: RunStatus, output: Option<Value>, error: Option<String>, )

Terminal transition of the run.

Source

pub fn write_var(&mut self, key: &str, value: Value, mode: &str)

Apply an assign/transform write with a reducer mode.

Source

pub fn progress(&self) -> Value

The steps counted as terminal/pending — for status views.

Source

pub fn summary(&self) -> Value

Trait Implementations§

Source§

impl Clone for RunState

Source§

fn clone(&self) -> RunState

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 RunState

Source§

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

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

impl<'de> Deserialize<'de> for RunState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for RunState

Source§

fn eq(&self, other: &RunState) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for RunState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RunState

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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, <T as TryFrom<U>>::Error>

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<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