From 6cfe487d46531040421a87ba461e5f3e7cfb79b4 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Tue, 10 Jan 2017 12:27:18 -0500 Subject: [PATCH] Change message topic service to be more short. This is just so that the topic doesn't end up being super long like `org.fedoraproject.prod.module_build_service.module.state.change` The new value will be: `org.fedoraproject.prod.mbs.module.state.change` Currently, the only thing listening for this is pdc-updater, which I will patch. --- module_build_service/messaging.py | 12 ++++++------ module_build_service/models.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/module_build_service/messaging.py b/module_build_service/messaging.py index 1b747f93..ea3792e9 100644 --- a/module_build_service/messaging.py +++ b/module_build_service/messaging.py @@ -87,7 +87,7 @@ class BaseMessage(object): properties = json.loads(msg.properties, encoding='utf8') service = properties.get('service') - if service not in ('koji', 'module_build_service'): + if service not in ('koji', 'mbs'): log.debug('Skipping msg due service=%s which is not related (msg=%r): ' % (service, msg)) return None @@ -130,8 +130,8 @@ class BaseMessage(object): msg.id, build_id, task_id, build_state, build_name, build_version, build_release) - elif service == 'module_build_service': - log.debug("Found module_build_service related msg: %s" % msg) + elif service == 'mbs': + log.debug("Found mbs related msg: %s" % msg) body = json.loads(msg.body, encoding='utf8') if topic == 'module.state.change': msg_obj = RidaModule( @@ -153,7 +153,7 @@ class BaseMessage(object): that the app looks for, otherwise None is returned """ regex_pattern = re.compile( - (r'(?Pbuildsys|module_build_service)(?:\.)' + (r'(?Pbuildsys|mbs)(?:\.)' r'(?Pbuild|repo|module)(?:(?:\.)' r'(?Pstate))?(?:\.)(?Pchange|done)$')) regex_results = re.search(regex_pattern, topic) @@ -193,7 +193,7 @@ class BaseMessage(object): repo_tag = msg_inner_msg.get('tag') msg_obj = KojiRepoChange(msg_id, repo_tag) - elif category == 'module_build_service' and object == 'module' and \ + elif category == 'mbs' and object == 'module' and \ subobject == 'state' and event == 'change': msg_obj = RidaModule( msg_id, msg_inner_msg.get('id'), msg_inner_msg.get('state')) @@ -258,7 +258,7 @@ def publish(topic, msg, conf, service): :param topic: the topic of the message (e.g. module.state.change) :param msg: the message contents of the message (typically JSON) :param conf: a Config object from the class in config.py - :param service: the system that is publishing the message (e.g. module_build_service) + :param service: the system that is publishing the message (e.g. mbs) :return: """ try: diff --git a/module_build_service/models.py b/module_build_service/models.py index 79126d9c..6d9264f0 100644 --- a/module_build_service/models.py +++ b/module_build_service/models.py @@ -177,7 +177,7 @@ class ModuleBuild(RidaBase): session.add(module) session.commit() module_build_service.messaging.publish( - service='module_build_service', + service='mbs', topic='module.state.change', msg=module.json(), # Note the state is "init" here... conf=conf, @@ -200,7 +200,7 @@ class ModuleBuild(RidaBase): log.debug("%r, state %r->%r" % (self, old_state, self.state)) if old_state != self.state: module_build_service.messaging.publish( - service='module_build_service', + service='mbs', topic='module.state.change', msg=self.json(), # Note the state is "init" here... conf=conf,