pub struct PubSubBroker {
config: PubSubConfig,
sender: Sender<Publication>,
subscriptions: RwLock<HashMap<u64, SubscriptionInfo>>,
subscription_counter: AtomicU64,
topic_stats: RwLock<HashMap<Topic, TopicStats>>,
retained: RwLock<HashMap<Topic, Vec<Publication>>>,
sequence: AtomicU64,
}Expand description
Pub/sub message broker.
Fields§
§config: PubSubConfigConfiguration.
sender: Sender<Publication>Broadcast sender for all publications.
subscriptions: RwLock<HashMap<u64, SubscriptionInfo>>Subscriptions by ID.
subscription_counter: AtomicU64Subscription counter.
topic_stats: RwLock<HashMap<Topic, TopicStats>>Topic statistics.
retained: RwLock<HashMap<Topic, Vec<Publication>>>Retained messages per topic.
sequence: AtomicU64Global message sequence.
Implementations§
Source§impl PubSubBroker
impl PubSubBroker
Sourcepub fn new(config: PubSubConfig) -> Arc<Self>
pub fn new(config: PubSubConfig) -> Arc<Self>
Create a new pub/sub broker.
Sourcepub fn subscribe(
self: &Arc<Self>,
subscriber: KernelId,
pattern: Topic,
) -> Subscription
pub fn subscribe( self: &Arc<Self>, subscriber: KernelId, pattern: Topic, ) -> Subscription
Subscribe to a topic.
Sourcepub fn unsubscribe(&self, subscription_id: u64)
pub fn unsubscribe(&self, subscription_id: u64)
Unsubscribe by subscription ID.
Sourcepub fn publish(
&self,
topic: Topic,
publisher: KernelId,
envelope: MessageEnvelope,
timestamp: HlcTimestamp,
) -> Result<u64>
pub fn publish( &self, topic: Topic, publisher: KernelId, envelope: MessageEnvelope, timestamp: HlcTimestamp, ) -> Result<u64>
Publish a message to a topic.
Sourcepub fn publish_qos(
&self,
topic: Topic,
publisher: KernelId,
envelope: MessageEnvelope,
timestamp: HlcTimestamp,
qos: QoS,
) -> Result<u64>
pub fn publish_qos( &self, topic: Topic, publisher: KernelId, envelope: MessageEnvelope, timestamp: HlcTimestamp, qos: QoS, ) -> Result<u64>
Publish with QoS setting.
Sourcepub fn publish_retained(
&self,
topic: Topic,
publisher: KernelId,
envelope: MessageEnvelope,
timestamp: HlcTimestamp,
) -> Result<u64>
pub fn publish_retained( &self, topic: Topic, publisher: KernelId, envelope: MessageEnvelope, timestamp: HlcTimestamp, ) -> Result<u64>
Publish a retained message.
Sourcepub fn get_retained(&self, topic: &Topic) -> Vec<Publication>
pub fn get_retained(&self, topic: &Topic) -> Vec<Publication>
Get retained messages for a topic.
Sourcepub fn clear_retained(&self, topic: &Topic)
pub fn clear_retained(&self, topic: &Topic)
Clear retained messages for a topic.
Sourcepub fn topic_info(&self, topic: &Topic) -> Option<TopicInfo>
pub fn topic_info(&self, topic: &Topic) -> Option<TopicInfo>
Get topic information.
Sourcepub fn list_topics(&self) -> Vec<Topic>
pub fn list_topics(&self) -> Vec<Topic>
List all topics with subscribers.
Sourcepub fn stats(&self) -> PubSubStats
pub fn stats(&self) -> PubSubStats
Get broker statistics.
Auto Trait Implementations§
impl !Freeze for PubSubBroker
impl !RefUnwindSafe for PubSubBroker
impl Send for PubSubBroker
impl Sync for PubSubBroker
impl Unpin for PubSubBroker
impl !UnwindSafe for PubSubBroker
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.