pub struct Executor { /* private fields */ }Expand description
Executor for running graph nodes in topological order.
§Thread Safety
The Executor is NOT thread-safe for concurrent executions on the same instance.
While execute() is async and takes &self (shared reference), the underlying
implementation assumes single-threaded access patterns:
self.nodesis a regularHashMapwithout synchronization- Multiple concurrent calls to
execute()would have data races when accessing nodes
§Safe Usage Patterns
- Single execution at a time: Only call
execute()once at a time per executor instance - Clone for parallelism: Create separate executor instances for parallel graph executions
- Sequential async: Use
.awaitto ensure executions don’t overlap
§Future Work
For true concurrent execution support, wrap nodes in Arc<RwLock<HashMap>> or similar.
Implementations§
Source§impl Executor
impl Executor
pub fn new() -> Self
Sourcepub fn with_cache(cache: CacheManager) -> Self
pub fn with_cache(cache: CacheManager) -> Self
Create a new executor with caching enabled
Sourcepub fn set_cache(&mut self, cache: CacheManager)
pub fn set_cache(&mut self, cache: CacheManager)
Enable caching for this executor
Sourcepub fn set_fallback_handler(&mut self, handler: FallbackHandler)
pub fn set_fallback_handler(&mut self, handler: FallbackHandler)
Set a global fallback handler used when node execution fails
Sourcepub fn cache(&self) -> Option<&CacheManager>
pub fn cache(&self) -> Option<&CacheManager>
Get the cache manager (if enabled)
Sourcepub fn metrics(&self) -> &ExecutionMetrics
pub fn metrics(&self) -> &ExecutionMetrics
Get execution metrics from last run
Sourcepub fn reset_metrics(&mut self)
pub fn reset_metrics(&mut self)
Reset execution metrics
Sourcepub fn from_graph_def(def: &GraphDef) -> Result<Self>
pub fn from_graph_def(def: &GraphDef) -> Result<Self>
Build executor from graph definition
Sourcepub fn register_node(&mut self, node: Box<dyn Node>)
pub fn register_node(&mut self, node: Box<dyn Node>)
Register a node with the executor
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Executor
impl !RefUnwindSafe for Executor
impl Send for Executor
impl Sync for Executor
impl Unpin for Executor
impl !UnwindSafe for Executor
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more