[zmq] add an introductive docstring on ZMQComm stable
authorDavid Douard <david.douard@logilab.fr>
Tue, 04 Dec 2012 16:16:08 +0100
branchstable
changeset 8614 52f576a7394c
parent 8613 9d792e9f1c79
child 8615 a24fbd24ede4
[zmq] add an introductive docstring on ZMQComm
server/cwzmq.py
--- a/server/cwzmq.py	Tue Dec 11 16:14:57 2012 +0100
+++ b/server/cwzmq.py	Tue Dec 04 16:16:08 2012 +0100
@@ -32,6 +32,23 @@
 ctx = zmq.Context()
 
 class ZMQComm(object):
+    """
+    A simple ZMQ-based notification bus.
+
+    There should at most one instance of this class attached to a
+    Repository. A typical usage may be something like::
+
+        def callback(msg):
+            self.info('received message: %s', ' '.join(msg))
+        repo.app_instances_bus.subscribe('hello', callback)
+
+    to subsribe to the 'hello' kind of message. On the other side, to
+    emit a notification, call::
+
+       repo.app_instances_bus.publish(['hello', 'world'])
+
+    See http://docs.cubicweb.org for more details.
+    """
     def __init__(self):
         self.ioloop = ioloop.IOLoop()
         self._topics = {}