Files needed for
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkvirtualenv my_virtualenv | |
git clone git://github.com/ralphbean/fedmsg.git | |
cd fedmsg | |
python setup.py develop | |
cd .. | |
mkdir my_consumer_project | |
cd my_consumer_project | |
# First copy my_consumer.py and setup.py from this gist into this directory. | |
# Then copy the development fedmsg config from the other git clone like this | |
cp -rf ../fedmsg/fedmsg.d/ . | |
# Finally, copy the my_consumer_config.py into this ./fedmsg.d/ directory. | |
# Setup your consumer by running | |
python setup.py develop | |
# Start the fedmsg-hub (which should pick up your consumer) with: | |
fedmsg-hub | |
# Go and make an edit to your account at https://admin.stg.fedoraproject.org/accounts | |
# You should see the dict-message get printed out. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Just an example consumer to show how to write a service that does stuff in | |
response to message on the `fedmsg bus <http://fedmsg.rtfd.org>`_. | |
Author: Ralph Bean | |
""" | |
import fedmsg.consumers | |
class MyTestConsumer(fedmsg.consumers.FedmsgConsumer): | |
# my_consumer_enabled must be set to True in the config in fedmsg.d/ for | |
# this consumer to be picked up and run when the fedmsg-hub starts. | |
config_key = "my_consumer_enabled" | |
# I'm only interested in messages from FAS | |
topic = "org.fedoraproject.stg.fas*" | |
def consume(self, message): | |
import pprint | |
print "Hello there.. I got a message from FAS. Its a python dict." | |
pprint.pprint(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" This is a config file that must appear in ./fedmsg.d/ alongside the other config files from the fedmsg development checkout. | |
In production, this should go into /etc/fedmsg.d/ but for development it can just live in your cwd/pwd. | |
""" | |
config = { | |
'my_consumer_enabled': True, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" A setuptool installer that crucially declares the consumer on an entry-point | |
that moksha is looking for. | |
Without this, fedmsg-hub won't find your consumer. | |
""" | |
from setuptools import setup | |
setup( | |
name='my_consumer_project', | |
entry_points=""" | |
[moksha.consumer] | |
hello = my_consumer:MyTestConsumer | |
""", | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment