From beb23103b054f43860f5e3e05149c6e22d91ce61 Mon Sep 17 00:00:00 2001 From: "Hiroyasu.OHYAMA" Date: Fri, 7 Oct 2016 18:07:00 +0900 Subject: [PATCH] [document] The example which is written in the developer guide of 'Notification Listener' doesn't work. I fixed the example which is described in developer guide to work fine. These are the main points of this correction. * specify namespace for NotificationFilter. * set 2 blank lines between class definitions according to E302 of pep8. * change argument of 'pool' to keyward arguemnt, because 4th argument of 'get_notification_listener' requires the name of message executor. Change-Id: I75800309f2294fe9f17ea2a2b1638de57ef2922e Closes-Bug: #1618394 --- oslo_messaging/notify/listener.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/oslo_messaging/notify/listener.py b/oslo_messaging/notify/listener.py index 968b6489e..9cd563721 100644 --- a/oslo_messaging/notify/listener.py +++ b/oslo_messaging/notify/listener.py @@ -92,15 +92,19 @@ A simple example of a notification listener with multiple endpoints might be:: from oslo_config import cfg import oslo_messaging + class NotificationEndpoint(object): - filter_rule = NotificationFilter(publisher_id='^compute.*') + filter_rule = oslo_messaging.NotificationFilter( + publisher_id='^compute.*') def warn(self, ctxt, publisher_id, event_type, payload, metadata): do_something(payload) + class ErrorEndpoint(object): - filter_rule = NotificationFilter(event_type='^instance\..*\.start$', - context={'ctxt_key': 'regexp'}) + filter_rule = oslo_messaging.NotificationFilter( + event_type='^instance\..*\.start$', + context={'ctxt_key': 'regexp'}) def error(self, ctxt, publisher_id, event_type, payload, metadata): do_something(payload) @@ -116,7 +120,7 @@ A simple example of a notification listener with multiple endpoints might be:: ] pool = "listener-workers" server = oslo_messaging.get_notification_listener(transport, targets, - endpoints, pool) + endpoints, pool=pool) server.start() server.wait()