pub struct ClusterPubSub { /* private fields */ }Expand description
Mediator that augments a local DistributedPubSub with a
cross-node topic table + transport. Clusters publish via
ClusterPubSub::publish_remote which fans out to all nodes that
have advertised the topic; receivers route the payload to local
subscribers using the codec registry.
Implementations§
Source§impl ClusterPubSub
impl ClusterPubSub
pub fn new( local: Arc<DistributedPubSub>, self_node: impl Into<String>, transport: Arc<dyn MediatorTransport>, ) -> Arc<Self>
Sourcepub fn register_decoder<F>(&self, type_id: impl Into<String>, decode: F)
pub fn register_decoder<F>(&self, type_id: impl Into<String>, decode: F)
Register a per-message-type decoder for inbound Forward PDUs.
type_id typically matches std::any::type_name::<M>(); the
decoder must deliver to local subscribers (and return true if
any delivery happened).
Sourcepub fn announce_to(&self, target_node: &str)
pub fn announce_to(&self, target_node: &str)
Announce currently-subscribed topics to a peer node. Caller drives
this on a tick (similar to ClusterDaemon).
Sourcepub fn apply_pdu(&self, pdu: MediatorPdu)
pub fn apply_pdu(&self, pdu: MediatorPdu)
Apply an inbound PDU received from the transport.
Sourcepub fn publish_remote<M, S>(
&self,
topic: &str,
msg: M,
type_id: impl Into<String>,
encode: S,
) -> usize
pub fn publish_remote<M, S>( &self, topic: &str, msg: M, type_id: impl Into<String>, encode: S, ) -> usize
Cross-node publish. Locally fan-out via the wrapped mediator, then forward the serialized payload to every remote node that has announced this topic.