pub struct PropagationTreeRouter { /* private fields */ }Expand description
Performs route resolving operations within a propagation tree.
The router parses the topology tree to generate a routing table, then
provides next_hop() and
dispatch() methods for directing
messages to the correct gateway.
Load balancing is achieved by tracking the number of connections (fanin) per gateway node.
Implementations§
Source§impl PropagationTreeRouter
impl PropagationTreeRouter
Sourcepub fn new(
root: &str,
topology: &TopologyTree,
fanout: usize,
) -> Result<Self, RouteResolvingError>
pub fn new( root: &str, topology: &TopologyTree, fanout: usize, ) -> Result<Self, RouteResolvingError>
Create a new router from a root node and topology tree.
The routing table is generated by traversing the tree from the root node’s position downward.
§Errors
Returns RouteResolvingError::InvalidRoot if the root node cannot
be found in the topology.
Sourcepub fn dispatch(&self, dst: &NodeSet) -> Vec<(NodeSet, NodeSet)>
pub fn dispatch(&self, dst: &NodeSet) -> Vec<(NodeSet, NodeSet)>
Dispatch nodes from a target nodeset to directly connected gateways.
Acts as an iterator, yielding (gateway_nodeset, target_nodes) pairs.
Provides load balancing between gateways. Remaining nodes that don’t
match any route are treated as directly connected.
Sourcepub fn next_hop(
&mut self,
dst: &NodeSet,
) -> Result<NodeSet, RouteResolvingError>
pub fn next_hop( &mut self, dst: &NodeSet, ) -> Result<NodeSet, RouteResolvingError>
Perform next-hop resolution for a single destination node.
Returns the best gateway to use based on current load (connections
tracked in nodes_fanin).
Sourcepub fn mark_unreachable(&mut self, dst: &str)
pub fn mark_unreachable(&mut self, dst: &str)
Mark a node as unreachable.
Sourcepub fn table(&self) -> &[RouteEntry]
pub fn table(&self) -> &[RouteEntry]
Get the routing table for inspection.