pyhermes

Version Badge Build Status

The Python interface to the Hermes message broker.

Documentation

The full documentation is at https://pyhermes.readthedocs.org.

Installation

To install pyhermes, simply:

pip install pyhermes

Then use it in a project:

import pyhermes

Features

  • TODO

Quickstart

Subscriber

To create handler for particular subscription topic decorate your function using subscribe decorator:

import pyhermes

@pyhermes.subscriber(topic='pl.allegro.pyhermes.sample-topic')
def handler(data):
    # process data

This function will be called every time there is new message published to the selected topic.

Publisher

Use publish function to publish data to some topic in hermes:

import pyhermes

@pyhermes.publisher(topic='pl.allegro.pyhermes.sample-topic')
def my_complex_function(a, b, c):
    result = a + b + c
    publish(my_complex_function._topic, {'complex_result': result})

You could publish directly result of the function as well:

import pyhermes

@pyhermes.publisher(topic='pl.allegro.pyhermes.sample-topic', auto_publish_result=True)
def my_complex_function(a, b, c):
    return {'complex_result': a + b + c}

Result of decorated function is automatically published to selected topic in hermes.

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements-test.txt
(myenv) $ python runtests.py

Credits

Tools used in rendering this package: