diff options
author | Li Ma <skywalker.nick@gmail.com> | 2015-03-04 22:14:05 -0800 |
---|---|---|
committer | Li Ma <skywalker.nick@gmail.com> | 2015-04-09 13:56:33 +0000 |
commit | f24a7dfa1569014b2caee13bea07d227bb3f8e1b (patch) | |
tree | b4dff9e3540d9a40fb6e8b66a61f1702bc1534fe | |
parent | d9c252088130a1d6d0ae87685fbf7bf07e63e583 (diff) | |
download | oslo-messaging-f24a7dfa1569014b2caee13bea07d227bb3f8e1b.tar.gz |
Add pluggability for matchmakers
Closes-Bug: #1291701
Change-Id: I2a10eca0760ef84f34e5dcdb8132845b88cd4b98
(cherry picked from commit 53fde06c44d004e28ba3741ac50386e046306285)
-rw-r--r-- | oslo_messaging/_drivers/impl_zmq.py | 32 | ||||
-rw-r--r-- | setup.cfg | 6 |
2 files changed, 28 insertions, 10 deletions
diff --git a/oslo_messaging/_drivers/impl_zmq.py b/oslo_messaging/_drivers/impl_zmq.py index 23961ee..7fcfd62 100644 --- a/oslo_messaging/_drivers/impl_zmq.py +++ b/oslo_messaging/_drivers/impl_zmq.py @@ -31,11 +31,12 @@ from oslo_utils import excutils from oslo_utils import importutils import six from six import moves +from stevedore import driver from oslo_messaging._drivers import base from oslo_messaging._drivers import common as rpc_common from oslo_messaging._executors import base as executor_base # FIXME(markmc) -from oslo_messaging._i18n import _, _LE +from oslo_messaging._i18n import _, _LE, _LW zmq = importutils.try_import('eventlet.green.zmq') @@ -56,8 +57,7 @@ zmq_opts = [ # The module.Class to use for matchmaking. cfg.StrOpt( 'rpc_zmq_matchmaker', - default=('oslo_messaging._drivers.' - 'matchmaker.MatchMakerLocalhost'), + default='local', help='MatchMaker driver.', ), @@ -793,14 +793,26 @@ def _multi_send(method, context, topic, msg, timeout=None, def _get_matchmaker(*args, **kwargs): global matchmaker + mm_name = CONF.rpc_zmq_matchmaker + + # Back compatibility for old class names + mm_mapping = { + 'oslo_messaging._drivers.matchmaker_redis.MatchMakerRedis': 'redis', + 'oslo_messaging._drivers.matchmaker_ring.MatchMakerRing': 'ring', + 'oslo_messaging._drivers.matchmaker.MatchMakerLocalhost': 'local', + 'oslo.messaging._drivers.matchmaker_redis.MatchMakerRedis': 'redis', + 'oslo.messaging._drivers.matchmaker_ring.MatchMakerRing': 'ring', + 'oslo.messaging._drivers.matchmaker.MatchMakerLocalhost': 'local'} + if mm_name in mm_mapping: + LOG.warn(_LW('rpc_zmq_matchmaker = %(old_val)s is deprecated. ' + 'It is suggested to change the value to %(new_val)s.'), + {'old_val': mm_name, 'new_val': mm_mapping[mm_name]}) + mm_name = mm_mapping[mm_name] + if not matchmaker: - mm = CONF.rpc_zmq_matchmaker - if mm.endswith('matchmaker.MatchMakerRing'): - mm.replace('matchmaker', 'matchmaker_ring') - LOG.warn(_('rpc_zmq_matchmaker = %(orig)s is deprecated; use' - ' %(new)s instead') % dict( - orig=CONF.rpc_zmq_matchmaker, new=mm)) - matchmaker = importutils.import_object(mm, *args, **kwargs) + mgr = driver.DriverManager('oslo.messaging.zmq.matchmaker', + mm_name) + matchmaker = mgr.driver(*args, **kwargs) return matchmaker @@ -55,6 +55,12 @@ oslo.messaging.notify.drivers = noop = oslo_messaging.notify._impl_noop:NoOpDriver routing = oslo_messaging.notify._impl_routing:RoutingDriver +oslo.messaging.zmq.matchmaker = + # Matchmakers for ZeroMQ + redis = oslo_messaging._drivers.matchmaker_redis:MatchMakerRedis + ring = oslo_messaging._drivers.matchmaker_ring:MatchMakerRing + local = oslo_messaging._drivers.matchmaker:MatchMakerLocalhost + oslo.config.opts = oslo.messaging = oslo_messaging.opts:list_opts |