add ability to publish to multiple topics
allow the ability to publish to multiple topics so we can have different consumers for different data. this is done by allowing users to specify a topic for each publisher rather than using the standard CONF option. DocImpact Closes-Bug: #1431922 Change-Id: Ib919cfa302e05653c788ea84a08eafbca4fe843c
This commit is contained in:
parent
2b478025fe
commit
ff2eaa345e
@ -200,8 +200,10 @@ class RPCPublisher(MessagingPublisher):
|
||||
|
||||
|
||||
class NotifierPublisher(MessagingPublisher):
|
||||
def __init__(self, parsed_url, topic):
|
||||
def __init__(self, parsed_url, default_topic):
|
||||
super(NotifierPublisher, self).__init__(parsed_url)
|
||||
options = urlparse.parse_qs(parsed_url.query)
|
||||
topic = options.get('topic', [default_topic])[-1]
|
||||
self.notifier = oslo.messaging.Notifier(
|
||||
messaging.get_transport(),
|
||||
driver=cfg.CONF.publisher_notifier.telemetry_driver,
|
||||
|
@ -176,6 +176,23 @@ class RpcOnlyPublisherTest(BasePublisherTestCase):
|
||||
self.assertEqual(expected, prepare.mock_calls)
|
||||
|
||||
|
||||
class NotifierOnlyPublisherTest(BasePublisherTestCase):
|
||||
|
||||
@mock.patch('oslo.messaging.Notifier')
|
||||
def test_publish_topic_override(self, notifier):
|
||||
msg_publisher.SampleNotifierPublisher(
|
||||
netutils.urlsplit('notifier://?topic=custom_topic'))
|
||||
notifier.assert_called_with(mock.ANY, topic='custom_topic',
|
||||
driver=mock.ANY, retry=mock.ANY,
|
||||
publisher_id=mock.ANY)
|
||||
|
||||
msg_publisher.EventNotifierPublisher(
|
||||
netutils.urlsplit('notifier://?topic=custom_event_topic'))
|
||||
notifier.assert_called_with(mock.ANY, topic='custom_event_topic',
|
||||
driver=mock.ANY, retry=mock.ANY,
|
||||
publisher_id=mock.ANY)
|
||||
|
||||
|
||||
class TestPublisher(testscenarios.testcase.WithScenarios,
|
||||
BasePublisherTestCase):
|
||||
scenarios = [
|
||||
|
Loading…
Reference in New Issue
Block a user