#279 Change message topic service to be shorter.
Merged 7 years ago by mprahl. Opened 7 years ago by ralph.

@@ -87,7 +87,7 @@ 

          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 @@ 

                          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 @@ 

          that the app looks for, otherwise None is returned

          """

          regex_pattern = re.compile(

-             (r'(?P<category>buildsys|module_build_service)(?:\.)'

+             (r'(?P<category>buildsys|mbs)(?:\.)'

               r'(?P<object>build|repo|module)(?:(?:\.)'

               r'(?P<subobject>state))?(?:\.)(?P<event>change|done)$'))

          regex_results = re.search(regex_pattern, topic)
@@ -193,7 +193,7 @@ 

                  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 @@ 

      :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:

@@ -177,7 +177,7 @@ 

          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 @@ 

          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,

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.

Pull-Request has been merged by mprahl

7 years ago