snakemq_pubsub Package

snakemq_pubsub Package

snakemq_pubsub.__init__

An implementation of the publish-subscribe pattern for snakeMQ.

copyright:(c) 2015 by Nicholas Repole and contributors. See AUTHORS for more details.
license:MIT - See LICENSE for more details.
class snakemq_pubsub.__init__.Broker(host, port, identity)[source]

Bases: snakemq_pubsub.__init__.MQConnectorMixin

A snakeMQ Pub/Sub broker.

Remove any remaining subscriptions on disconnect.

on_recv(conn, ident, message)[source]

Handle PUBLISH, SUBSCRIBE, and UNSUBSCRIBE commands.

class snakemq_pubsub.__init__.BrokerClient(broker_host, broker_port, broker_identity, identity)[source]

Bases: snakemq_pubsub.__init__.MQConnectorMixin

Client connection to a broker server.

Publisher and Subscriber inherit from this class.

class snakemq_pubsub.__init__.MQConnectorMixin(identity)[source]

Bases: object

One end of a snakeMQ connection.

Broker, Subscriber, and Publisher all inherit from this class.

Log when the link connects.

Log when the link disconnects.

messenger_on_connect(conn, ident)[source]

Log any new messenger connections.

messenger_on_disconnect(conn, ident)[source]

Log any new new messenger disconnections.

on_drop(ident, message)[source]

Handle a dropped message.

on_recv(conn, ident, message)[source]

Handle an incoming message.

Will typically be overriden by an inheriting class.

run(runtime=None)[source]

Run the snakeMQ stack and listen for messages.

stop()[source]

Stop the message broker.

class snakemq_pubsub.__init__.Publisher(broker_host, broker_port, broker_identity, identity)[source]

Bases: snakemq_pubsub.__init__.BrokerClient

Manages publishing messages to a message broker.

publish(channel, message)[source]

Publish a message on the supplied channel.

class snakemq_pubsub.__init__.Subscriber(broker_host, broker_port, broker_identity, identity, on_recv)[source]

Bases: snakemq_pubsub.__init__.BrokerClient

A snakeMQ Pub/Sub subscriber.

messenger_on_connect(conn, ident)[source]

Resubscribe to any prior subscriptions.

on_recv(conn, ident, message)[source]

Forward a received message to the prior provided callback.

subscribe(channel)[source]

Subscribe to the provided channel.

unsubscribe(channel)[source]

Unsubscribe from the provided channel.