Python Patron API

Client API

__init__(topic, callback, crypto=True, patron_id=None)

topic—Topic of data being consumed, may contain wildcards
callback—A callable function that will be passed the data read from the brewer
crypto—Should we accept encrypted data
patron_id—If set, use this as the patrons ID rather than generating one

Creating a patron is simple: you provide the topic you wish to subscribe to, which may contain wildcards. The supported wildcards are * and **. The * wildcard will be a wildcard between two periods, whereas the ** wildcard will match between two words.

For example, topic.*.test will match, but will not match while topic.**.test would match both and

When data is received, it will be passed to the callback provided.


Called when connected to a pubkeeper server. Allows the protocol implementation to create cipher keys, or any other setup necessary.


brewers—List of brewers that we are going to be subscribing to

List element format

topic—The actual topic the brewer is publishing
brewer_id—UUID of the brewer
brewer_config—Any brewer-specific configuration, i.e. cipher info
brew—Brew method of producing our data

This method is called when a brewer_notify packet is received. Since the patron may subscribe to wildcard topics, the topic provided is the literal topic of the brewer. The brewer_config also provides any brewer-specific configurations such as cryptographic keys needed for decrypting data.


brewer_id—UUID of the brewer

Called when a brewer_removed packet is received. Any resources created may be destroyed here.


Called when disconnected from a pubkeeper server, to cleanup any protocol specific data associated to this brewer

_handle_callback(brewer_id, data)

brewer_id—UUID of the brewer
data—Data received from the brewer

This method is called from a specific brew when it receives information from the brewer. This method can look to the brewer's configuration and decrypt data as necessary before calling this patron's callback in the user's application.

results matching ""

    No results matching ""