The gemstone.event module

Event transports

class gemstone.event.BaseEventTransport[source]

Base class for defining event transports.

The basic workflow would be the following:

emit_event(event_name, event_body)[source]

Emits an event of type event_name with the event_body content using the current event transport.

  • event_name
  • event_body

on_event_received(event_name, event_body)[source]

Handles generic event. This function should treat every event that is received with the designated handler function.

  • event_name – the name of the event to be handled
  • event_body – the body of the event to be handled

register_event_handler(handler_func, handled_event_name)[source]

Registers a function to handle all events of type handled_event_name

  • handler_func – the handler function
  • handled_event_name – the handled event type
run_on_main_thread(func, args=None, kwargs=None)[source]

Runs the func callable on the main thread, by using the provided microservice instance’s IOLoop.

  • func – callable to run on the main thread
  • args – tuple or list with the positional arguments.
  • kwargs – dict with the keyword arguments.


Used by the microservice instance to send reference to itself. Do not override this.


Starts accepting and handling events.

class gemstone.event.RedisEventTransport(redis_url)[source]

Event transport that uses a Redis server as message transport by using the PUBSUB mechanism.

Parameters:redis_url – A string that specifies the network location of the redis server: - redis://[:password@]hostaddr:port/dbnumber (plaintext) - rediss://[:password@]hostaddr:port/dbnumber (over TLS) - unix://[:password@]/path/to/socket?db=dbnumber (Unix socket)
class gemstone.event.RabbitMqEventTransport(host='', port=5672, username='', password='', **connection_options)[source]

Event transport via RabbitMQ server.

  • host – ipv4 or hostname
  • port – the port where the server listens
  • username – username used for authentication
  • password – password used for authentication
  • connection_options – extra arguments that will be used in pika.BlockingConnection initialization.