Skip to main content

PropagationTreeRouter

Struct PropagationTreeRouter 

Source
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

Source

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.

Source

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.

Source

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).

Source

pub fn mark_unreachable(&mut self, dst: &str)

Mark a node as unreachable.

Source

pub fn root(&self) -> &str

Get the root node name.

Source

pub fn fanout(&self) -> usize

Get the fanout setting.

Source

pub fn table(&self) -> &[RouteEntry]

Get the routing table for inspection.

Trait Implementations§

Source§

impl Debug for PropagationTreeRouter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.