class documentation

class PublisherConsistencyListener(SubscribeListener):

View In Hierarchy

This class is used to solve the problem that sometimes we create a publisher and then immediately publish a message, before the subscribers have set up their connections.

Call attach() to attach the listener to a publisher. It sets up a buffer of outgoing messages, then when a new connection occurs, sends the messages in the buffer.

Call detach() to detach the listener from the publisher and restore the original publish methods.

After some particular timeout (default to 1 second), the listener stops buffering messages as it is assumed by this point all subscribers will have successfully set up their connections.

Method attach Overrides the publisher's publish method, and attaches a subscribe listener to the publisher, effectively routing incoming connections and outgoing publish requests through this class instance
Method detach Restores the publisher's original publish method and unhooks the subscribe listeners, effectively finishing with this object
Method peer_subscribe Called whenever there's a new subscription.
Method publish_override The publisher's publish method is replaced with this publish method which checks for timeout and if we haven't timed out, buffers outgoing messages in preparation for new subscriptions
Method timed_out Checks to see how much time has elapsed since the publisher was created
Class Variable timeout Undocumented
Instance Variable attached Undocumented
Instance Variable established_time Undocumented
Instance Variable lock Undocumented
Instance Variable msg_buffer Undocumented
Instance Variable publish Undocumented
Instance Variable publisher Undocumented
def attach(self, publisher):

Overrides the publisher's publish method, and attaches a subscribe listener to the publisher, effectively routing incoming connections and outgoing publish requests through this class instance

def detach(self):

Restores the publisher's original publish method and unhooks the subscribe listeners, effectively finishing with this object

def peer_subscribe(self, topic_name, topic_publish, peer_publish):

Called whenever there's a new subscription.

If we're still inside the subscription setup window, then we publish any buffered messages to the peer.

We also check if we're timed out, but if we are we don't detach (due to threading complications), we just don't propagate buffered messages

def publish_override(self, message):

The publisher's publish method is replaced with this publish method which checks for timeout and if we haven't timed out, buffers outgoing messages in preparation for new subscriptions

def timed_out(self):

Checks to see how much time has elapsed since the publisher was created

timeout: int =

Undocumented

attached: bool =

Undocumented

established_time =

Undocumented

lock =

Undocumented

msg_buffer: list =

Undocumented

publish =

Undocumented

publisher =

Undocumented