pub struct Pregel<S: State> { /* private fields */ }Expand description
The Pregel execution engine.
This implements the core superstep loop:
- Load checkpoint (if resuming)
- Write initial input to channels
- Loop:
- Find triggered nodes
- Execute nodes in parallel
- Apply writes to channels with reducers
- Handle interrupts/commands
- Save checkpoint
- Yield stream events
- Return final state
Implementations§
Source§impl<S: State> Pregel<S>
impl<S: State> Pregel<S>
Sourcepub fn new(
nodes: HashMap<String, PregelNode<S>>,
channels: HashMap<String, Box<dyn BaseChannel>>,
checkpointer: Option<Arc<dyn BaseCheckpointSaver>>,
entry_point: String,
finish_points: HashSet<String>,
edges: HashMap<String, Vec<String>>,
) -> Self
pub fn new( nodes: HashMap<String, PregelNode<S>>, channels: HashMap<String, Box<dyn BaseChannel>>, checkpointer: Option<Arc<dyn BaseCheckpointSaver>>, entry_point: String, finish_points: HashSet<String>, edges: HashMap<String, Vec<String>>, ) -> Self
Create a new Pregel executor
Sourcepub fn with_recursion_limit(self, limit: usize) -> Self
pub fn with_recursion_limit(self, limit: usize) -> Self
Set the recursion limit
Sourcepub async fn invoke(&mut self, input: S, config: Config) -> Result<S>
pub async fn invoke(&mut self, input: S, config: Config) -> Result<S>
Execute the graph with the given input and configuration
Sourcepub async fn stream(
&mut self,
input: S,
config: Config,
mode: StreamMode,
) -> Result<Pin<Box<dyn Stream<Item = Result<StreamEvent>> + Send>>>
pub async fn stream( &mut self, input: S, config: Config, mode: StreamMode, ) -> Result<Pin<Box<dyn Stream<Item = Result<StreamEvent>> + Send>>>
Stream execution events
Sourcepub async fn get_state(
&self,
config: &Config,
) -> Result<Option<StateSnapshot<S>>>
pub async fn get_state( &self, config: &Config, ) -> Result<Option<StateSnapshot<S>>>
Get the current state snapshot
Sourcepub async fn get_state_history(
&self,
config: &Config,
limit: Option<usize>,
) -> Result<Vec<StateSnapshot<S>>>
pub async fn get_state_history( &self, config: &Config, limit: Option<usize>, ) -> Result<Vec<StateSnapshot<S>>>
Get state history
Auto Trait Implementations§
impl<S> Freeze for Pregel<S>
impl<S> !RefUnwindSafe for Pregel<S>
impl<S> Send for Pregel<S>
impl<S> Sync for Pregel<S>
impl<S> Unpin for Pregel<S>
impl<S> UnsafeUnpin for Pregel<S>
impl<S> !UnwindSafe for Pregel<S>
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