Skip to main content

LongRunningNode

Trait LongRunningNode 

Source
pub trait LongRunningNode<Context, Action>: Send + Sync
where Context: Send + Sync + 'static, Action: ActionType + Send + Sync + 'static + Debug, Self::State: Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static, Self::Output: Send + 'static,
{ type State; type Output; // Required methods fn process<'life0, 'life1, 'async_trait>( &'life0 self, state: Option<Self::State>, ctx: &'life1 mut Context, ) -> Pin<Box<dyn Future<Output = Result<LongRunningOutcome<Self::Output, Self::State>, FloxideError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn id(&self) -> NodeId; }
Expand description

Trait for nodes that handle long-running processes with checkpoints.

A LongRunningNode is capable of processing work incrementally, saving its state between executions, and resuming from the last checkpoint.

Required Associated Types§

Source

type State

Type representing the node’s processing state

Source

type Output

Type representing the final output

Required Methods§

Source

fn process<'life0, 'life1, 'async_trait>( &'life0 self, state: Option<Self::State>, ctx: &'life1 mut Context, ) -> Pin<Box<dyn Future<Output = Result<LongRunningOutcome<Self::Output, Self::State>, FloxideError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Process the next step, potentially suspending execution

Source

fn id(&self) -> NodeId

Get the node’s unique identifier

Implementors§

Source§

impl<Context, Action, State, Output, F> LongRunningNode<Context, Action> for SimpleLongRunningNode<Context, Action, State, Output, F>
where Context: Send + Sync + 'static, Action: ActionType + Send + Sync + 'static + Debug, State: Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static, Output: Send + Sync + 'static, F: Fn(Option<State>, &mut Context) -> Result<LongRunningOutcome<Output, State>, FloxideError> + Send + Sync + 'static,

Source§

type State = State

Source§

type Output = Output