allegro/pyhermes

Name: pyhermes

Owner: Allegro Tech

Description: The Python interface to the Hermes message broker.

Created: 2016-04-14 06:47:39.0

Updated: 2018-05-15 07:14:43.0

Pushed: 2017-01-27 09:27:27.0

Homepage:

Size: 45

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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:

install pyhermes

Then use it in a project:

rt pyhermes
Features
Quickstart
Subscriber

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

rt pyhermes

ermes.subscriber(topic='pl.allegro.pyhermes.sample-topic')
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:

rt pyhermes

ermes.publisher(topic='pl.allegro.pyhermes.sample-topic')
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:

rt pyhermes

ermes.publisher(topic='pl.allegro.pyhermes.sample-topic', auto_publish_result=True)
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?

ce <YOURVIRTUALENV>/bin/activate
nv) $ pip install -r requirements-test.txt
nv) $ python runtests.py
Credits

Tools used in rendering this package:


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.