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
Size: 45
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
The Python interface to the Hermes message broker.
The full documentation is at https://pyhermes.readthedocs.org.
To install pyhermes, simply:
install pyhermes
Then use it in a project:
rt pyhermes
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.
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.
Does the code actually work?
ce <YOURVIRTUALENV>/bin/activate
nv) $ pip install -r requirements-test.txt
nv) $ python runtests.py
Tools used in rendering this package: