pub struct EventDrivenWorkflow<Event, Context, Action>where
Event: Send + 'static,
Context: Send + Sync + 'static,
Action: ActionType + Send + Sync + 'static + Default,{ /* private fields */ }Expand description
A workflow that processes events using event-driven nodes
Implementations§
Source§impl<Event, Context, Action> EventDrivenWorkflow<Event, Context, Action>
impl<Event, Context, Action> EventDrivenWorkflow<Event, Context, Action>
Sourcepub fn new(
initial_node: Arc<Mutex<dyn EventDrivenNode<Event, Context, Action>>>,
termination_action: Action,
) -> Self
pub fn new( initial_node: Arc<Mutex<dyn EventDrivenNode<Event, Context, Action>>>, termination_action: Action, ) -> Self
Create a new event-driven workflow with an initial node
Sourcepub fn add_node(
&mut self,
node: Arc<Mutex<dyn EventDrivenNode<Event, Context, Action>>>,
)
pub fn add_node( &mut self, node: Arc<Mutex<dyn EventDrivenNode<Event, Context, Action>>>, )
Add a node to the workflow
Sourcepub fn set_route(&mut self, from_id: &NodeId, action: Action, to_id: &NodeId)
pub fn set_route(&mut self, from_id: &NodeId, action: Action, to_id: &NodeId)
Set a route from one node to another based on an action
Sourcepub fn set_route_with_validation(
&mut self,
from_id: &NodeId,
action: Action,
to_id: &NodeId,
) -> Result<(), FloxideError>
pub fn set_route_with_validation( &mut self, from_id: &NodeId, action: Action, to_id: &NodeId, ) -> Result<(), FloxideError>
Sets a route with validation to ensure proper event flow
This method ensures that processor nodes (non-event sources) route back to valid event sources, preventing the “not an event source” error during execution.
§Arguments
from_id- The source node IDaction- The action that triggers this routeto_id- The destination node ID
§Returns
Result<(), FloxideError>- Ok if the route is valid, Error otherwise
Sourcepub async fn execute(&self, ctx: &mut Context) -> Result<(), FloxideError>
pub async fn execute(&self, ctx: &mut Context) -> Result<(), FloxideError>
Execute the workflow, processing events until the termination action is returned
Sourcepub async fn execute_with_timeout(
&self,
ctx: &mut Context,
timeout: Duration,
) -> Result<(), FloxideError>
pub async fn execute_with_timeout( &self, ctx: &mut Context, timeout: Duration, ) -> Result<(), FloxideError>
Execute the workflow with a timeout
Auto Trait Implementations§
impl<Event, Context, Action> Freeze for EventDrivenWorkflow<Event, Context, Action>where
Action: Freeze,
impl<Event, Context, Action> !RefUnwindSafe for EventDrivenWorkflow<Event, Context, Action>
impl<Event, Context, Action> Send for EventDrivenWorkflow<Event, Context, Action>
impl<Event, Context, Action> Sync for EventDrivenWorkflow<Event, Context, Action>
impl<Event, Context, Action> Unpin for EventDrivenWorkflow<Event, Context, Action>where
Action: Unpin,
impl<Event, Context, Action> !UnwindSafe for EventDrivenWorkflow<Event, Context, Action>
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
Mutably borrows from an owned value. Read more