Skip to main content

FlowManager

Struct FlowManager 

Source
pub struct FlowManager { /* private fields */ }
Expand description

High-level operational surface for managed flows.

Every mutation method follows the same template: read current flow, validate the requested state machine transition, persist via update_with_revision, append an audit event. RevisionMismatch errors trigger a single re-fetch + retry; persistent contention surfaces to the caller.

Implementations§

Source§

impl FlowManager

Source

pub fn new(store: Arc<dyn FlowStore>) -> Self

Source

pub async fn create_managed( &self, input: CreateManagedInput, ) -> Result<Flow, FlowError>

Insert a fresh flow in Created status. Caller receives the canonical record with assigned id/timestamps.

Source

pub async fn get(&self, id: Uuid) -> Result<Option<Flow>, FlowError>

Source

pub async fn list_by_owner(&self, owner: &str) -> Result<Vec<Flow>, FlowError>

Source

pub async fn list_by_status( &self, status: FlowStatus, ) -> Result<Vec<Flow>, FlowError>

Source

pub async fn start_running(&self, id: Uuid) -> Result<Flow, FlowError>

Created → Running.

Source

pub async fn set_waiting( &self, id: Uuid, wait_json: Value, ) -> Result<Flow, FlowError>

Running → Waiting. wait_json describes what the flow is blocked on (timer deadline, NATS subject, manual signal). Inspected by the wait/resume engine in 14.4.

Source

pub async fn resume( &self, id: Uuid, state_patch: Option<Value>, ) -> Result<Flow, FlowError>

Waiting → Running. Clears wait_json. Optional state_patch merges shallowly into state_json so callers can record what unblocked them.

Source

pub async fn finish( &self, id: Uuid, final_state: Option<Value>, ) -> Result<Flow, FlowError>

Running → Finished. Optional final state patch is merged before transition.

Source

pub async fn fail( &self, id: Uuid, reason: impl Into<String>, ) -> Result<Flow, FlowError>

Running/Waiting → Failed. reason is recorded in the event log and stamped under state_json.failure.

Source

pub async fn request_cancel(&self, id: Uuid) -> Result<Flow, FlowError>

Set sticky cancel intent without changing status. Useful when an in-flight step needs to drain before the flow can flip to Cancelled.

Source

pub async fn cancel(&self, id: Uuid) -> Result<Flow, FlowError>

Force the flow to Cancelled. Allowed from any non-terminal status.

Source

pub async fn update_state( &self, id: Uuid, patch: Value, next_step: Option<String>, ) -> Result<Flow, FlowError>

Mutate state_json without changing status. current_step is optionally updated in the same revision.

Source

pub async fn create_mirrored( &self, input: CreateManagedInput, ) -> Result<Flow, FlowError>

Create a mirrored flow. The flow is born in Running status because the externally-observed work is typically already in flight. Use record_step_observation to keep its steps in sync.

Source

pub async fn record_step_observation( &self, observation: StepObservation, ) -> Result<FlowStep, FlowError>

Upsert-style: if a step with the same (flow_id, run_id) exists, update its status/result; otherwise insert a fresh step row. Designed to be called from a NATS subscriber (or CLI/cron bridge).

Source

pub async fn list_steps( &self, flow_id: Uuid, ) -> Result<Vec<FlowStep>, FlowError>

Read all steps linked to a flow, ordered oldest-first.

Trait Implementations§

Source§

impl Clone for FlowManager

Source§

fn clone(&self) -> FlowManager

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

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = Infallible

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