Skip to main content

Module component_graph

Module component_graph 

Source
Expand description

Component dependency graph — the single source of truth for configuration Component Dependency Graph — the single source of truth for DrasiLib configuration.

The ComponentGraph maintains a directed graph of all components (Instance, Sources, Queries, Reactions, BootstrapProviders, IdentityProviders) and their bidirectional relationships. The DrasiLib instance itself is the root node.

All three managers (SourceManager, QueryManager, ReactionManager) share the same Arc<RwLock<ComponentGraph>>. Managers register components in the graph first (registry-first pattern), then create and store runtime instances. The graph is the authoritative source for component relationships, dependency tracking, and lifecycle events.

§Event Emission

The graph emits ComponentEvents via a built-in broadcast::Sender whenever components are added, removed, or change status. Subscribers (ComponentGraphSource, EventHistory, external consumers) receive events directly from the graph.

§Status Update Channel

Components report status changes via a shared mpsc::Sender<ComponentUpdate>. A dedicated graph update loop (spawned externally) receives from this channel and applies updates to the graph, emitting broadcast events. This decouples components from the graph lock — status reporting is fire-and-forget.

Structural mutations (add_component, remove_component, add_relationship) and command-initiated transitions (Starting, Stopping) are applied directly by managers, which hold the graph write lock on the cold path.

Structs§

ComponentGraph
Central component dependency graph — the single source of truth.
ComponentNode
A node in the component graph.
ComponentStatusHandle
A clonable handle for reading, writing, and reporting component status.
GraphEdge
A serializable edge in the graph snapshot
GraphSnapshot
Serializable snapshot of the entire component graph.
GraphTransaction
A transactional wrapper for batching graph mutations.

Enums§

ComponentKind
Type of component in the graph
ComponentUpdate
A status or metric update sent from a component to the graph update loop.
RelationshipKind
Type of relationship between components (bidirectional pairs)

Functions§

wait_for_status
Wait for a component to reach one of the target statuses, with a timeout.

Type Aliases§

ComponentUpdateReceiver
Receiver half of the component update channel.
ComponentUpdateSender
Sender half of the component update channel.