"Fossies" - the Fresh Open Source Software Archive

Member "buildbot-2.5.1/buildbot/mq/connector.py" (24 Nov 2019, 2775 Bytes) of package /linux/misc/buildbot-2.5.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "connector.py" see the Fossies "Dox" file reference documentation.

    1 # This file is part of Buildbot.  Buildbot is free software: you can
    2 # redistribute it and/or modify it under the terms of the GNU General Public
    3 # License as published by the Free Software Foundation, version 2.
    4 #
    5 # This program is distributed in the hope that it will be useful, but WITHOUT
    6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    7 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    8 # details.
    9 #
   10 # You should have received a copy of the GNU General Public License along with
   11 # this program; if not, write to the Free Software Foundation, Inc., 51
   12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   13 #
   14 # Copyright Buildbot Team Members
   15 
   16 
   17 from twisted.python.reflect import namedObject
   18 
   19 from buildbot.util import service
   20 
   21 
   22 class MQConnector(service.ReconfigurableServiceMixin, service.AsyncMultiService):
   23 
   24     classes = {
   25         'simple': {
   26             'class': "buildbot.mq.simple.SimpleMQ",
   27             'keys': set(['debug']),
   28         },
   29         'wamp': {
   30             'class': "buildbot.mq.wamp.WampMQ",
   31             'keys': set(["router_url", "realm", "wamp_debug_level"]),
   32         },
   33     }
   34     name = 'mq'
   35 
   36     def __init__(self):
   37         super().__init__()
   38         self.impl = None  # set in setup
   39         self.impl_type = None  # set in setup
   40 
   41     def setup(self):
   42         assert not self.impl
   43 
   44         # imports are done locally so that we don't try to import
   45         # implementation-specific modules unless they're required.
   46         typ = self.master.config.mq['type']
   47         assert typ in self.classes  # this is checked by MasterConfig
   48         self.impl_type = typ
   49         cls = namedObject(self.classes[typ]['class'])
   50         self.impl = cls()
   51 
   52         # set up the impl as a child service
   53         self.impl.setServiceParent(self)
   54 
   55         # configure it (early)
   56         self.impl.reconfigServiceWithBuildbotConfig(self.master.config)
   57 
   58         # copy the methods onto this object for ease of access
   59         self.produce = self.impl.produce
   60         self.startConsuming = self.impl.startConsuming
   61         self.waitUntilEvent = self.impl.waitUntilEvent
   62 
   63     def reconfigServiceWithBuildbotConfig(self, new_config):
   64         # double-check -- the master ensures this in config checks
   65         assert self.impl_type == new_config.mq['type']
   66 
   67         return super().reconfigServiceWithBuildbotConfig(new_config)
   68 
   69     def produce(self, routing_key, data):
   70         # will be patched after configuration to point to the running
   71         # implementation's method
   72         raise NotImplementedError
   73 
   74     def startConsuming(self, callback, filter, persistent_name=None):
   75         # will be patched after configuration to point to the running
   76         # implementation's method
   77         raise NotImplementedError