pub struct FederationManager { /* private fields */ }Expand description
Federation manager that coordinates all peer connections.
The manager maintains a set of federation links and a namespace registry, routing messages to the appropriate peers based on address patterns.
Implementations§
Source§impl FederationManager
impl FederationManager
Sourcepub fn new(config: FederationConfig) -> Self
pub fn new(config: FederationConfig) -> Self
Create a new federation manager
Sourcepub fn event_sender(&self) -> Sender<LinkEvent>
pub fn event_sender(&self) -> Sender<LinkEvent>
Get the event sender for creating new links
Sourcepub fn take_event_receiver(&mut self) -> Option<Receiver<LinkEvent>>
pub fn take_event_receiver(&mut self) -> Option<Receiver<LinkEvent>>
Take the event receiver (can only be called once).
The caller should process events in a loop to handle messages from federation peers.
Sourcepub fn create_link(&self, sender: Arc<dyn TransportSender>) -> FederationLink
pub fn create_link(&self, sender: Arc<dyn TransportSender>) -> FederationLink
Create a federation link for an established transport connection.
The link will perform the CLASP handshake, exchange federation metadata,
and begin relaying messages. Call link.run(receiver) to start it.
Sourcepub async fn process_event(&self, event: &LinkEvent)
pub async fn process_event(&self, event: &LinkEvent)
Process a link event, updating internal state.
Call this for each event received from take_event_receiver().
Returns the event for further processing by the router.
Sourcepub async fn should_forward(&self, address: &str, origin: Option<&str>) -> bool
pub async fn should_forward(&self, address: &str, origin: Option<&str>) -> bool
Check if an address should be forwarded to federation peers
Sourcepub async fn peers_for_address(
&self,
address: &str,
exclude_origin: Option<&str>,
) -> Vec<String>
pub async fn peers_for_address( &self, address: &str, exclude_origin: Option<&str>, ) -> Vec<String>
Get peers that should receive a message for the given address
Sourcepub async fn peer_info(&self, router_id: &str) -> Option<PeerInfo>
pub async fn peer_info(&self, router_id: &str) -> Option<PeerInfo>
Get information about a peer
Sourcepub async fn active_peers(&self) -> Vec<PeerInfo>
pub async fn active_peers(&self) -> Vec<PeerInfo>
Get all active peers
Sourcepub async fn peer_count(&self) -> usize
pub async fn peer_count(&self) -> usize
Get peer count
Sourcepub fn mode(&self) -> &FederationMode
pub fn mode(&self) -> &FederationMode
Get the federation mode
Sourcepub fn owned_namespaces(&self) -> &[String]
pub fn owned_namespaces(&self) -> &[String]
Get local namespace patterns