Events()

class Events(parent=None, wait=3000, chunk_size=1024)

This class describes the Events listenner to listen and process events from Lagoon.

Parameters:
  • wait (integer) – Specify how many seconds to wait before reconnecting to server.

  • chunk_size (integer) – Specify chunk size when reading and parsing an event.

listen()

Connect and starts streaming events from the server.

Returns:

Events listener

Return type:

Events

start()

Starts processing events and trigger the callbacks.

stop()

Stop listening to the event stream

subscribe(event='*', callback=None)

Subscribe to an event’s topic and define its callback

Parameters:
  • event (string) – The event topic. It can be a specific event (item.created.Media), a part of topic (item.created), or a wildcard (*)

  • callback (function) – The callback function

Tip

An event topic is a string, constructed as follows:
  • ‘category.verb’

Some topics can include a detail at the end to quickly filter events based on type:
  • ‘item.created.Media’

  • ‘edge.updated.Assigned’

Returns:

The callback

Return type:

Callback object _Callback

unsubscribe(event='*', callback=None)

Unsubscribe to an event topic and remove its callback

Parameters:
  • event (string) – The event topic

  • callback (Callback object _Callback) – The callback object