Python Brew API

Client API

These methods will be used by an application instantiating a brew implementation.

configure(context)

context—Override default settings of the brew

Brews will define a set of options that are used by the brew to manage different aspects of itself. Typically these will be hostname, port, thresholds, and the like. You may provide a dictionary to override these defaults.

Example

brew = BrewImplementation()
brew.configure({
  'ws_host': 'localhost',
  'ws_port': 9999
})

Development API

These methods should not need to be called by an application, but are necessary to implement your own brew.

@classmethod: get_settings(cls)

Return a dictionary of available brew settings and their default values.

start()

Starts the brew. This method is called by the client after all brews have been added. If necessary, you may allocate any resources necessary for publishing or receiving data that are not dependent on the brewer or the patron using this brew.

stop()

Stops the brew. This method is called during shutdown and you should free all resources for your implementation.

create_brewer(brewer)

This method is called when a new brewer is added to the client. You may allocate any resources necessary for this brewer. The return value of this method, if set, must be a dictionary and its values will be included with the Brewer Registration Packet sent to the Pubkeeper server.

destroy_brewer(brewer)

This method is called when a brewer is removed from the client. You may free any resources that were created. The return value of this method, if set, must be a dictionary and its values will be included in the Brewer Unregister Packet sent to the Pubkeeper server.

create_patron(patron)

This method is called when a new patron is added to the client. You may allocate any resources necessary for this patron. The return value of this method, if set, must be a dictionary and its values will be included with the Patron Registration Packet sent to the Pubkeeper server.

destroy_patron(patron)

This method is called when a patron is removed from the client. You may free any resources that were created. The return value of this method, if set, must be a dictionary and its values will be included with the Patron Unregister Packet sent to the Pubkeeper server.

start_brewer(brewer_id, topic, patron_id, patron)

brewer_id—The ID of your brewer that will be publishing topic—Topic this brewer is publishing to patron_id—ID of the remote patron who is subscribing to your topic patron—Details that the patron has registered with the server

This alerts the brew that a new patron has joined the network and to begin sending data to it. The brewer_id of a brewer registered with the server for the specified topic is provided. The remote patron_id is also provided along with any details that the patron registered with the Pubkeeper server.

stop_brewer(brewer_id, topic, patron_id)

brewer_id—The ID of your brewer that is publishing topic—Topic this brewer is publishing to patron_id—ID of the remote patron who is subscribing to your topic

Inverse of the above. This is called when a specific patron has left the network. The method does not shutdown all brewing but rather alerts the brew that the specific patron_id has unsubscribed from the brewer_id.

start_patron(patron_id, topic, brewer_id, brewer)

patron_id—The ID of your patron that will be subscribing topic—Topic this patron is subscribing to brewer_id—ID of the remote brewer who is publishing to your topic brewer—Details that the brewer had registered with the server

Alert brew that a new brewer has joined the network and to begin receiving data from it. The patron_id of the patron you created and registered with the server is provided along with the full topic of the publishing brewer. Since your patron can be set up with a topic containing wildcards, the topic provided is not the patron's topic but the full topic of the publishing brewer. Also given is the publishing brewer's brewer_id and any details that the brewer registered with the Pubkeeper server.

stop_patron(patron_id, topic, brewer_id)

patron_id—The ID of your patron that is subscribing topic—Topic of the brewer subscribing to brewer_id—ID of the remote brewer who is publishing to your topic

Inverse of the above. This is called when a specific brewer has left the network. The method does not shutdown all patrons but rather alerts the brew that the specific brewer_id is no longer publishing for the specific topic.

brew(brewer_id, topic, data, patrons)

brewer_id—The ID of the brewer that is publishing topic—Topic being published to data—This will be data of raw bytes to be published patrons—Set of all patrons the brewer is brewing to

This method is called by the brewer in response to the user's application. Use the allocated resources to send the provided data to the list of patrons. Your brew may, or may not, need the list of patrons to make the data available to them.

results matching ""

    No results matching ""