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
impl FlowManager
pub fn new(store: Arc<dyn FlowStore>) -> Self
Sourcepub async fn create_managed(
&self,
input: CreateManagedInput,
) -> Result<Flow, FlowError>
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.
pub async fn get(&self, id: Uuid) -> Result<Option<Flow>, FlowError>
pub async fn list_by_owner(&self, owner: &str) -> Result<Vec<Flow>, FlowError>
pub async fn list_by_status( &self, status: FlowStatus, ) -> Result<Vec<Flow>, FlowError>
Sourcepub async fn set_waiting(
&self,
id: Uuid,
wait_json: Value,
) -> Result<Flow, FlowError>
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.
Sourcepub async fn resume(
&self,
id: Uuid,
state_patch: Option<Value>,
) -> Result<Flow, FlowError>
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.
Sourcepub async fn finish(
&self,
id: Uuid,
final_state: Option<Value>,
) -> Result<Flow, FlowError>
pub async fn finish( &self, id: Uuid, final_state: Option<Value>, ) -> Result<Flow, FlowError>
Running → Finished. Optional final state patch is merged before transition.
Sourcepub async fn fail(
&self,
id: Uuid,
reason: impl Into<String>,
) -> Result<Flow, FlowError>
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.
Sourcepub async fn request_cancel(&self, id: Uuid) -> Result<Flow, FlowError>
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.
Sourcepub async fn cancel(&self, id: Uuid) -> Result<Flow, FlowError>
pub async fn cancel(&self, id: Uuid) -> Result<Flow, FlowError>
Force the flow to Cancelled. Allowed from any non-terminal status.
Sourcepub async fn update_state(
&self,
id: Uuid,
patch: Value,
next_step: Option<String>,
) -> Result<Flow, FlowError>
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.
Sourcepub async fn create_mirrored(
&self,
input: CreateManagedInput,
) -> Result<Flow, FlowError>
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.
Sourcepub async fn record_step_observation(
&self,
observation: StepObservation,
) -> Result<FlowStep, FlowError>
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).
Trait Implementations§
Source§impl Clone for FlowManager
impl Clone for FlowManager
Source§fn clone(&self) -> FlowManager
fn clone(&self) -> FlowManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FlowManager
impl !RefUnwindSafe for FlowManager
impl Send for FlowManager
impl Sync for FlowManager
impl Unpin for FlowManager
impl UnsafeUnpin for FlowManager
impl !UnwindSafe for FlowManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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