Add pluggability for matchmakers
Closes-Bug: #1291701 Change-Id: I2a10eca0760ef84f34e5dcdb8132845b88cd4b98
This commit is contained in:
parent
097fb235b2
commit
53fde06c44
@ -31,11 +31,12 @@ from oslo_utils import excutils
|
|||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
import six
|
||||||
from six import moves
|
from six import moves
|
||||||
|
from stevedore import driver
|
||||||
|
|
||||||
from oslo_messaging._drivers import base
|
from oslo_messaging._drivers import base
|
||||||
from oslo_messaging._drivers import common as rpc_common
|
from oslo_messaging._drivers import common as rpc_common
|
||||||
from oslo_messaging._executors import base as executor_base # FIXME(markmc)
|
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')
|
zmq = importutils.try_import('eventlet.green.zmq')
|
||||||
@ -56,8 +57,7 @@ zmq_opts = [
|
|||||||
# The module.Class to use for matchmaking.
|
# The module.Class to use for matchmaking.
|
||||||
cfg.StrOpt(
|
cfg.StrOpt(
|
||||||
'rpc_zmq_matchmaker',
|
'rpc_zmq_matchmaker',
|
||||||
default=('oslo_messaging._drivers.'
|
default='local',
|
||||||
'matchmaker.MatchMakerLocalhost'),
|
|
||||||
help='MatchMaker driver.',
|
help='MatchMaker driver.',
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -793,14 +793,26 @@ def _multi_send(method, context, topic, msg, timeout=None,
|
|||||||
|
|
||||||
def _get_matchmaker(*args, **kwargs):
|
def _get_matchmaker(*args, **kwargs):
|
||||||
global matchmaker
|
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:
|
if not matchmaker:
|
||||||
mm = CONF.rpc_zmq_matchmaker
|
mgr = driver.DriverManager('oslo.messaging.zmq.matchmaker',
|
||||||
if mm.endswith('matchmaker.MatchMakerRing'):
|
mm_name)
|
||||||
mm.replace('matchmaker', 'matchmaker_ring')
|
matchmaker = mgr.driver(*args, **kwargs)
|
||||||
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)
|
|
||||||
return matchmaker
|
return matchmaker
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,6 +55,12 @@ oslo.messaging.notify.drivers =
|
|||||||
noop = oslo_messaging.notify._impl_noop:NoOpDriver
|
noop = oslo_messaging.notify._impl_noop:NoOpDriver
|
||||||
routing = oslo_messaging.notify._impl_routing:RoutingDriver
|
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.config.opts =
|
||||||
oslo.messaging = oslo_messaging.opts:list_opts
|
oslo.messaging = oslo_messaging.opts:list_opts
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user