[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
This commit is contained in:
Hiroyasu.OHYAMA 2016-10-07 18:07:00 +09:00
parent 6357a45f82
commit beb23103b0

View File

@ -92,15 +92,19 @@ A simple example of a notification listener with multiple endpoints might be::
from oslo_config import cfg from oslo_config import cfg
import oslo_messaging import oslo_messaging
class NotificationEndpoint(object): 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): def warn(self, ctxt, publisher_id, event_type, payload, metadata):
do_something(payload) do_something(payload)
class ErrorEndpoint(object): class ErrorEndpoint(object):
filter_rule = NotificationFilter(event_type='^instance\..*\.start$', filter_rule = oslo_messaging.NotificationFilter(
context={'ctxt_key': 'regexp'}) event_type='^instance\..*\.start$',
context={'ctxt_key': 'regexp'})
def error(self, ctxt, publisher_id, event_type, payload, metadata): def error(self, ctxt, publisher_id, event_type, payload, metadata):
do_something(payload) do_something(payload)
@ -116,7 +120,7 @@ A simple example of a notification listener with multiple endpoints might be::
] ]
pool = "listener-workers" pool = "listener-workers"
server = oslo_messaging.get_notification_listener(transport, targets, server = oslo_messaging.get_notification_listener(transport, targets,
endpoints, pool) endpoints, pool=pool)
server.start() server.start()
server.wait() server.wait()