Struct PubSubBroker
pub struct PubSubBroker {
config: PubSubConfig,
sender: Sender<Publication>,
subscriptions: RwLock<RawRwLock, HashMap<u64, SubscriptionInfo>>,
subscription_counter: AtomicU64,
topic_stats: RwLock<RawRwLock, HashMap<Topic, TopicStats>>,
retained: RwLock<RawRwLock, HashMap<Topic, Vec<Publication>>>,
sequence: AtomicU64,
}Expand description
Pub/sub message broker.
Fields§
§config: PubSubConfig§sender: Sender<Publication>§subscriptions: RwLock<RawRwLock, HashMap<u64, SubscriptionInfo>>§subscription_counter: AtomicU64§topic_stats: RwLock<RawRwLock, HashMap<Topic, TopicStats>>§retained: RwLock<RawRwLock, HashMap<Topic, Vec<Publication>>>§sequence: AtomicU64Implementations§
§impl PubSubBroker
impl PubSubBroker
pub fn new(config: PubSubConfig) -> Arc<PubSubBroker>
pub fn new(config: PubSubConfig) -> Arc<PubSubBroker>
Create a new pub/sub broker.
pub fn subscribe(
self: &Arc<PubSubBroker>,
subscriber: KernelId,
pattern: Topic,
) -> Subscription
pub fn subscribe( self: &Arc<PubSubBroker>, subscriber: KernelId, pattern: Topic, ) -> Subscription
Subscribe to a topic.
pub fn unsubscribe(&self, subscription_id: u64)
pub fn unsubscribe(&self, subscription_id: u64)
Unsubscribe by subscription ID.
pub fn publish(
&self,
topic: Topic,
publisher: KernelId,
envelope: MessageEnvelope,
timestamp: HlcTimestamp,
) -> Result<u64, RingKernelError>
pub fn publish( &self, topic: Topic, publisher: KernelId, envelope: MessageEnvelope, timestamp: HlcTimestamp, ) -> Result<u64, RingKernelError>
Publish a message to a topic.
pub fn publish_qos(
&self,
topic: Topic,
publisher: KernelId,
envelope: MessageEnvelope,
timestamp: HlcTimestamp,
qos: QoS,
) -> Result<u64, RingKernelError>
pub fn publish_qos( &self, topic: Topic, publisher: KernelId, envelope: MessageEnvelope, timestamp: HlcTimestamp, qos: QoS, ) -> Result<u64, RingKernelError>
Publish with QoS setting.
pub fn publish_retained(
&self,
topic: Topic,
publisher: KernelId,
envelope: MessageEnvelope,
timestamp: HlcTimestamp,
) -> Result<u64, RingKernelError>
pub fn publish_retained( &self, topic: Topic, publisher: KernelId, envelope: MessageEnvelope, timestamp: HlcTimestamp, ) -> Result<u64, RingKernelError>
Publish a retained message.
pub fn get_retained(&self, topic: &Topic) -> Vec<Publication>
pub fn get_retained(&self, topic: &Topic) -> Vec<Publication>
Get retained messages for a topic.
pub fn clear_retained(&self, topic: &Topic)
pub fn clear_retained(&self, topic: &Topic)
Clear retained messages for a topic.
pub fn topic_info(&self, topic: &Topic) -> Option<TopicInfo>
pub fn topic_info(&self, topic: &Topic) -> Option<TopicInfo>
Get topic information.
pub fn list_topics(&self) -> Vec<Topic>
pub fn list_topics(&self) -> Vec<Topic>
List all topics with subscribers.
pub 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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§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.