PubSub¶
Purpose¶
The Publish-Subscribe (PubSub) engine implements a peer-to-peer topic-based publish-subscribe protocol. It is responsible for handling P2P protocol messages and managing subscriptions. Local engines send and receive pub/sub messages via the Router.
~Usage~¶
The Router engine interfaces with the PubSub engine directly, while other local engines use the Router to subscribe to topics and send messages destined to the multicast address of a pub/sub topic, which the Router then forwards to PubSub for delivery.
State¶
PubSubRoutingTable¶
Todo
Pending a proper description.
Messages received¶
TopicAdvert¶
Topic advertisement by a publisher.
Reception:
Record with fields:
-
topic
: TopicIdentityTopic ID
-
tags
: listList of optional tags to facilitate subscribing to new topics with relevant tags
-
publisher
: EngineIdentityPubSub engine ID of publisher
-
created
: TimeCreation time
-
sig
: SignatureSignature over the above fields by
topic
Triggers:
TopicAdvert
Subscribe¶
Subscribe to a topic at another peer.
Reception:
Record with fields:
topic
: TopicIdentity Pub/sub topic identity.
Triggers:
Unsubscribe¶
Unsubscribe from a topic at other peers.
Reception:
Record with fields:
topic
: TopicIdentity Pub/sub topic identity.
Triggers:
Event¶
An event sent to a topic.
Reception:
Record with fields:
-
topic
: TopicIdentityTopic the event is published to
-
publisher
: EngineIdentityPubSub engine identity of pulisher
-
seq
: u32Sequence number of publisher
-
deps
: VecEvents this event depends on
-
seen
: VecIndependent events recently seen
-
body
: VecEncapsulated EngineMessage
-
sig
: SignatureSignature by
publisher
over the above fields
Triggers:
Event
EngineMessage¶
A message sent to a pub/sub topic by an engine.
Reception:
Record with fields:
-
src
: EngineIdentitySource engine identity
-
dst
: DestinationIdentityDestination identity
-
id
: u64Message ID: unique per
src
-dst
pairs
-
reply_to
: Optionid
of a previous message this message is in reply to
-
expiry
OptionExpiry time for outgoing messages. See P2PMessage & TransportMessage.
-
rprefs
: Option<RoutingPrefs>Routing preferences
-
tprefs
: Option<TransportPrefs>Transport preferences
-
protocol
: ProtocolProtocol & version used in
body
-
body
: VecSerialized message body
-
sig
: OptionSignature over the above fields by
src
Triggers:
SubscribeRequest¶
Subscription request.
Reception:
Record with fields:
topic
: TopicIdentity Pub/sub topic identity.
Triggers:
Result
UnsubscribeRequest¶
Unsubscription request.
Reception:
Record with fields:
topic
: TopicIdentity Pub/sub topic identity.
Triggers:
Result
StartAdvertRequest¶
Start advertising a topic in the network.
Reception:
Record with fields:
topic
: TopicIdentity Pub/sub topic identity.
scope
: RoutingScope Whether the topic should be advertised over the network.
advert
: Option<TopicAdvertV1> Topic advertisement to send to the network, when thescope
allows.
Triggers:
Result
StopAdvertRequest¶
Stop advertising a topic in the network.
Reception:
Record with fields:
topic
: TopicIdentity Pub/sub topic identity.
Triggers:
Result
Notifications sent¶
TopicSubscribed¶
Notification about a topic that was successfully subscribed at another peer.
Record with fields:
topic
: TopicIdentity Pub/sub topic identity.
TopicUnsubscribed¶
Notification about a topic that was successfully unsubscribed at another peer.
Record with fields:
topic
: TopicIdentity Pub/sub topic identity.
TopicAdvertReceived¶
A TopicAdvert has been received from another peer.
Record with fields:
topic
: TopicIdentity Pub/sub topic identity.
scope
: RoutingScope Whether the topic should be advertised over the network.
advert
: Option<TopicAdvertV1> Topic advertisement to send to the network, when thescope
allows.
Message flow¶
sequenceDiagram
%% TODO
Router -) PubSub: EngineMessage
PubSub -) PubSub: Event
PubSub -) Router: EngineMessage
Router -) Any Local Engine: EngineMessage
Any Local Engine -) Router: EngineMessage
Router -) PubSub: EngineMessage
PubSub -) PubSub: Event
PubSub ->>+ PubSub_R: Subscribe
PubSub_R -->>- PubSub: SubscribeAck
PubSub ->>+ PubSub_R: Unsubscribe
PubSub_R -->>- PubSub: UnsubscribeAck
Router ->>+ PubSub: SubscribeRequest
PubSub -->>- Router: SubscribeResponse
Router ->>+ PubSub: UnsubscribeRequest
PubSub -->>- Router: UnsubscribeResponse
Router ->>+ PubSub: StartAdvertRequest
PubSub -->>- Router: StartAdvertResponse
Router ->>+ PubSub: StopAdvertRequest
PubSub -->>- Router: StopAdvertResponse
PubSub -) Any Local Engine: TopicSubscribed
PubSub -) Any Local Engine: TopicUnsubscribed
PubSub -) Any Local Engine: TopicAdvertReceived
(Wiki) links on this page
- Router
- Router
- PubSubRoutingTable
- TopicAdvert
- TopicAdvertV1
- TopicIdentity
- EngineIdentity
- TopicAdvertReceived
- Subscribe
- TopicRequestV1
- TopicIdentity
- SubscribeAck
- Unsubscribe
- TopicRequestV1
- TopicIdentity
- UnsubscribeAck
- Event
- EventV1
- TopicIdentity
- EngineIdentity
- EngineMessage
- EngineMessage
- EngineMessage to PubSub
- EngineMessageV1
- EngineIdentity
- DestinationIdentity
- P2PMessage to Transport
- TransportMessage
- RoutingPrefs
- TransportPrefs
- Event
- SubscribeRequest
- TopicRequestV1
- TopicIdentity
- TopicRequestV1
- UnsubscribeRequest
- TopicRequestV1
- TopicIdentity
- TopicRequestV1
- StartAdvertRequest
- TopicCreateRequestV1
- TopicIdentity
- RoutingScope
- TopicAdvertV1
- TopicRequestV1
- StopAdvertRequest
- TopicRequestV1
- TopicIdentity
- TopicRequestV1
- TopicSubscribed
- TopicRequestV1
- TopicIdentity
- TopicUnsubscribed
- TopicRequestV1
- TopicIdentity
- TopicAdvertReceived
- TopicAdvert
- TopicCreateRequestV1
- TopicIdentity
- RoutingScope
- TopicAdvertV1