Skip to main content

Runner

Struct Runner 

Source
pub struct Runner<S: Clone + 'static> { /* private fields */ }
Expand description

Executes a Workflow step by step, handling retries, waits, and routing.

Implementations§

Source§

impl<S: Clone + 'static> Runner<S>

Source

pub fn new(wf: Workflow<S>) -> Self

Create a runner for the given workflow with default limits (max_steps: 10,000, max_retries: 3).

Source

pub fn with_max_steps(self, max_steps: usize) -> Self

Prevent accidental infinite loops.

Source

pub fn with_max_retries(self, max_retries: usize) -> Self

Set the maximum consecutive retries per agent before failing.

Source

pub fn on_step(self, cb: impl FnMut(&StepEvent<'_>) + 'static) -> Self

Register a callback that fires after each successful agent step.

Source

pub fn on_error(self, cb: impl FnMut(&ErrorEvent<'_>) + 'static) -> Self

Register a callback that fires when an agent errors or a limit is exceeded.

Source

pub fn with_tracing(self) -> Self

Set both hooks to print step transitions and errors to stderr.

Source

pub fn run(&mut self, state: S, ctx: &mut Ctx) -> Result<S, StepError>

Run the workflow to completion, returning the final state or an error. Can be called multiple times on the same runner.

Auto Trait Implementations§

§

impl<S> Freeze for Runner<S>

§

impl<S> !RefUnwindSafe for Runner<S>

§

impl<S> !Send for Runner<S>

§

impl<S> !Sync for Runner<S>

§

impl<S> Unpin for Runner<S>

§

impl<S> UnsafeUnpin for Runner<S>

§

impl<S> !UnwindSafe for Runner<S>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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