pub struct DependencyGraph { /* private fields */ }Expand description
Dependency graph for node relationships
Maintains a directed graph of node dependencies where an edge from A to B means “A depends on B” (B must start before A).
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn from_configs(configs: &[NodeConfig]) -> Result<Self>
pub fn from_configs(configs: &[NodeConfig]) -> Result<Self>
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate the dependency graph
Checks for:
- Circular dependencies
- Undefined dependency references
Sourcepub fn topological_sort(&self) -> Result<Vec<String>>
pub fn topological_sort(&self) -> Result<Vec<String>>
Sourcepub fn reverse_topological_sort(&self) -> Result<Vec<String>>
pub fn reverse_topological_sort(&self) -> Result<Vec<String>>
Get reverse topological sort (for shutdown order)
Returns nodes in reverse dependency order (dependents before dependencies). This is the order for stopping nodes.
Sourcepub fn startup_plan(&self) -> Result<StartupPlan>
pub fn startup_plan(&self) -> Result<StartupPlan>
Get startup plan with nodes grouped by dependency level
Nodes at the same level have no dependencies on each other and can be started in parallel.
§Returns
StartupPlan with nodes grouped by level
Sourcepub fn shutdown_plan(&self) -> Result<ShutdownPlan>
pub fn shutdown_plan(&self) -> Result<ShutdownPlan>
Get shutdown plan (reverse of startup plan)
Sourcepub fn get_all_dependencies(&self, node_id: &str) -> HashSet<String>
pub fn get_all_dependencies(&self, node_id: &str) -> HashSet<String>
Get all dependencies of a node (transitive closure)
Returns all nodes that must be started before this node.
Sourcepub fn get_all_dependents(&self, node_id: &str) -> HashSet<String>
pub fn get_all_dependents(&self, node_id: &str) -> HashSet<String>
Get all dependents of a node (transitive closure)
Returns all nodes that must be stopped before this node can be stopped.
Sourcepub fn can_start(&self, node_id: &str, running: &HashSet<String>) -> bool
pub fn can_start(&self, node_id: &str, running: &HashSet<String>) -> bool
Check if a node can be started
Returns true if all dependencies are in the provided running set.
Sourcepub fn can_stop(&self, node_id: &str, running: &HashSet<String>) -> bool
pub fn can_stop(&self, node_id: &str, running: &HashSet<String>) -> bool
Check if a node can be stopped
Returns true if no dependents are in the provided running set.
Sourcepub fn get_direct_dependents(&self, node_id: &str) -> Vec<String>
pub fn get_direct_dependents(&self, node_id: &str) -> Vec<String>
Get nodes that depend on this node
Sourcepub fn get_direct_dependencies(&self, node_id: &str) -> Vec<String>
pub fn get_direct_dependencies(&self, node_id: &str) -> Vec<String>
Get nodes this node depends on
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of nodes in the graph
Trait Implementations§
Source§impl Clone for DependencyGraph
impl Clone for DependencyGraph
Source§fn clone(&self) -> DependencyGraph
fn clone(&self) -> DependencyGraph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DependencyGraph
impl Debug for DependencyGraph
Auto Trait Implementations§
impl Freeze for DependencyGraph
impl RefUnwindSafe for DependencyGraph
impl Send for DependencyGraph
impl Sync for DependencyGraph
impl Unpin for DependencyGraph
impl UnwindSafe for DependencyGraph
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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