mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-13 19:19:48 +08:00
Merge #8 Add listening for notifications as well.
This commit is contained in:
@@ -25,21 +25,41 @@
|
||||
|
||||
|
||||
def publish(topic, msg, backend, modname='rida'):
|
||||
""" Publish a single message to a given backend, and return. """
|
||||
try:
|
||||
handler = _messaging_backends[backend]['publish']
|
||||
except KeyError:
|
||||
raise KeyError("No messaging backend found for %r" % backend)
|
||||
return handler(topic, msg, modname=modname)
|
||||
|
||||
def listen(backend, **kwargs):
|
||||
""" Yield messages from a given messaging backend.
|
||||
|
||||
The ``**kwargs`` arguments will be passed on to the backend to do some
|
||||
backend-specific connection handling, throttling, or filtering.
|
||||
"""
|
||||
try:
|
||||
handler = _messaging_backends[backend]['listen']
|
||||
except KeyError:
|
||||
raise KeyError("No messaging backend found for %r" % backend)
|
||||
|
||||
for event in handler(**kwargs):
|
||||
yield event
|
||||
|
||||
|
||||
def _fedmsg_publish(topic, msg, modname):
|
||||
import fedmsg
|
||||
return fedmsg.publish(topic=topic, msg=msg, modname=modname)
|
||||
|
||||
|
||||
def _fedmsg_listen(**kwargs):
|
||||
import fedmsg
|
||||
for name, endpoint, topic, msg in fedmsg.tail_messages(**kwargs):
|
||||
yield msg
|
||||
|
||||
_messaging_backends = {
|
||||
'fedmsg': {
|
||||
'publish': _fedmsg_publish,
|
||||
#'listen': _fedmsg_listen, # For later...
|
||||
'listen': _fedmsg_listen,
|
||||
},
|
||||
}
|
||||
|
||||
18
ridad.py
18
ridad.py
@@ -23,6 +23,7 @@
|
||||
# SOFTWARE.
|
||||
#
|
||||
# Written by Petr Šabata <contyk@redhat.com>
|
||||
# Ralph Bean <rbean@redhat.com>
|
||||
|
||||
"""The module build orchestrator for Modularity, the builder.
|
||||
|
||||
@@ -30,10 +31,25 @@ This is the main component of the orchestrator and is responsible for
|
||||
proper scheduling component builds in the supported build systems.
|
||||
"""
|
||||
|
||||
# TODO: Load configuration.
|
||||
import rida.config
|
||||
import rida.messaging
|
||||
|
||||
# TODO: Load the config file from environment
|
||||
config = rida.config.from_file("rida.conf")
|
||||
|
||||
# TODO: Listen for bus messages from build systems about builds being done.
|
||||
for msg in rida.messaging.listen(backend=config.messaging):
|
||||
print("Saw %r with %r" % (msg['topic'], msg))
|
||||
if '.buildsys.build.state.change' in msg['topic']:
|
||||
print("A build changed state in koji!!")
|
||||
elif '.rida.module.state.change' in msg['topic']:
|
||||
print("Our frontend says that a module changed state!!")
|
||||
else:
|
||||
pass
|
||||
|
||||
# TODO: Periodically check the state of the build systems' tasks, in case some
|
||||
# messages got lost.
|
||||
# XXX - should we just do this with a cronjob external to this process?
|
||||
# TODO: Emit messages about the module build being done.
|
||||
# TODO; Watch the database and process modules in the wait state.
|
||||
# TODO: Construct the name of the tag/target according to the policy and record
|
||||
|
||||
Reference in New Issue
Block a user