Skip to main content

CompiledGraph

Struct CompiledGraph 

Source
pub struct CompiledGraph<S>
where S: GraphStateTrait,
{ /* private fields */ }
Expand description

已编译完成、可执行的状态图。

Implementations§

Source§

impl<S> CompiledGraph<S>
where S: GraphStateTrait,

Source

pub fn with_checkpointer<C>(self, checkpointer: C) -> Self
where C: Checkpointer<S> + 'static,

挂载一个检查点存储实现。图的执行并不强依赖检查点存在。

Source

pub async fn invoke(&self, state: S) -> Result<S>

按有向图顺序依次执行节点:

  • 从 entry 节点开始;
  • 每个节点运行后通过 apply_update 合并状态;
  • 若存在条件边,则优先根据 router 结果选下一跳;
  • 否则选择第一条普通出边;
  • 若到达 finish 节点或无出边,则结束执行。
Source

pub async fn resume(&self, node_id: &str) -> Result<S>

从某个节点的检查点恢复执行的占位接口:

  • 若未挂载 Checkpointer,返回错误;
  • 若找不到对应节点的检查点,同样返回错误;
  • 目前的实现会从加载出的状态重新执行整张图(仍从 entry 开始), 未来可以扩展为从任意节点继续执行。

Auto Trait Implementations§

§

impl<S> Freeze for CompiledGraph<S>

§

impl<S> !RefUnwindSafe for CompiledGraph<S>

§

impl<S> Send for CompiledGraph<S>

§

impl<S> Sync for CompiledGraph<S>

§

impl<S> Unpin for CompiledGraph<S>

§

impl<S> UnsafeUnpin for CompiledGraph<S>

§

impl<S> !UnwindSafe for CompiledGraph<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.