Skip to the content.

Baroque

Baroque

Events made easy

Baroque is an event brokering framework with a honey-sweet interface.

It features an out-of-the-box efficient implementation of the publish-subscriber pattern enabled by high-level abstractions, allowing quick development of event-driven applications.

The main focus of Baroque is provide a human-friendly interface to event brokering operations, in terms of API and configuration.

Features in a nutshell

Baroque is…

Installation

Baroque runs on Python 3.5+

Install the latest stable version with pip:

$ pip install baroque

As Baroque is currently under heavy development, its API may change without notice: fetch the latest modifications on the development branch with:

$ pip install git+https://github.com/baroquehq/baroque.git@dev

Getting started

from baroque import Baroque, Reactor, EventFactory

# Pub-sub is easy with Baroque!

# 1. Instantiate the event broker:
brq = Baroque()

# 2. Create reactors, which basically are functions. This one - in example -
# prints the input event's content to the console as JSON
reactor = Reactor(lambda event: print(event.json()))

# 3. Now tell the broker that we want to run our reactor upon events of any type:
brq.on_any_event_run(reactor)


# 4. Good! Now let's publish an event on the broker:
event = EventFactory.new(payload=dict(key1='value1', key2='value2'), owner='me')
brq.publish(event)

# ... and our terminal should display something like this:
'''
{
    "timestamp": "2017-03-28T23:20:57Z",
	"owner": "me",
	"links": [],
	"tags": [],
	"payload": {
	   "key2": "value2",
	   "key1": "value1"},
	"status": "unpublished",
    ...
}
'''

Documentation

License

MIT license