pub struct NamespaceManager { /* private fields */ }Expand description
Manages namespace ownership across federated peers.
Each peer declares the address patterns it owns. When a message arrives, the namespace manager determines which peers should receive it.
Implementations§
Source§impl NamespaceManager
impl NamespaceManager
Sourcepub fn new(local_namespaces: Vec<String>) -> Self
pub fn new(local_namespaces: Vec<String>) -> Self
Create a new namespace manager with local patterns
Sourcepub fn register_peer(&mut self, router_id: &str, patterns: Vec<String>)
pub fn register_peer(&mut self, router_id: &str, patterns: Vec<String>)
Register a peer’s namespace patterns
Sourcepub fn remove_peer(&mut self, router_id: &str)
pub fn remove_peer(&mut self, router_id: &str)
Remove a peer’s namespace registrations
Sourcepub fn peers_for_address(
&self,
address: &str,
exclude_origin: Option<&str>,
) -> Vec<String>
pub fn peers_for_address( &self, address: &str, exclude_origin: Option<&str>, ) -> Vec<String>
Get all peers that should receive a message for the given address.
Returns peer router IDs whose namespace patterns match the address. Excludes the origin peer to prevent loops.
Sourcepub fn is_local(&self, address: &str) -> bool
pub fn is_local(&self, address: &str) -> bool
Check if an address belongs to the local router’s namespace
Sourcepub fn is_remote(&self, address: &str) -> bool
pub fn is_remote(&self, address: &str) -> bool
Check if an address belongs to any peer’s namespace
Sourcepub fn find_conflicts(&self) -> Vec<(String, String, String)>
pub fn find_conflicts(&self) -> Vec<(String, String, String)>
Check for namespace conflicts between peers.
Returns pairs of (pattern, peer_a, peer_b) for overlapping namespaces.
Sourcepub fn peer_patterns(&self, router_id: &str) -> Option<&Vec<String>>
pub fn peer_patterns(&self, router_id: &str) -> Option<&Vec<String>>
Get a peer’s registered namespaces
Sourcepub fn local_patterns(&self) -> &[String]
pub fn local_patterns(&self) -> &[String]
Get local namespaces
Sourcepub fn peer_count(&self) -> usize
pub fn peer_count(&self) -> usize
Number of registered peers