[Checkins] SVN: zc.resumelb/trunk/src/zc/resumelb/ - When defining workers that register with ZooKeeper, you can now

jim cvs-admin at zope.org
Thu May 3 17:23:42 UTC 2012


Log message for revision 125635:
  - When defining workers that register with ZooKeeper, you can now
    supply a description in the paste.ini file that shows up in
    ZooKeeper.  While the pid alone provides enough information to find
    a worker, often a description (e.g. instance name or path) can make
    it easier.
  

Changed:
  U   zc.resumelb/trunk/src/zc/resumelb/README.txt
  U   zc.resumelb/trunk/src/zc/resumelb/tests.py
  U   zc.resumelb/trunk/src/zc/resumelb/zk.py
  U   zc.resumelb/trunk/src/zc/resumelb/zk.test

-=-
Modified: zc.resumelb/trunk/src/zc/resumelb/README.txt
===================================================================
--- zc.resumelb/trunk/src/zc/resumelb/README.txt	2012-05-03 17:21:02 UTC (rev 125634)
+++ zc.resumelb/trunk/src/zc/resumelb/README.txt	2012-05-03 17:23:38 UTC (rev 125635)
@@ -250,6 +250,12 @@
   identifier as a prefix.  For example "1.22" indicated request number
   22 from lb 1.
 
+- When defining workers that register with ZooKeeper, you can now
+  supply a description in the paste.ini file that shows up in
+  ZooKeeper.  While the pid alone provides enough information to find
+  a worker, often a description (e.g. instance name or path) can make
+  it easier.
+
 0.4.0 (2012-04-27)
 ------------------
 

Modified: zc.resumelb/trunk/src/zc/resumelb/tests.py
===================================================================
--- zc.resumelb/trunk/src/zc/resumelb/tests.py	2012-05-03 17:21:02 UTC (rev 125634)
+++ zc.resumelb/trunk/src/zc/resumelb/tests.py	2012-05-03 17:23:38 UTC (rev 125635)
@@ -132,6 +132,7 @@
                         r'\[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\] "(.+) \d+\.\d+'
                         ),
                      'ACCESS'),
+                    (re.compile(r"u'pid': \d+"), "u'pid': PID"),
                     ])
                 ) + manuel.capture.Manuel(),
             'zk.test',

Modified: zc.resumelb/trunk/src/zc/resumelb/zk.py
===================================================================
--- zc.resumelb/trunk/src/zc/resumelb/zk.py	2012-05-03 17:21:02 UTC (rev 125634)
+++ zc.resumelb/trunk/src/zc/resumelb/zk.py	2012-05-03 17:23:38 UTC (rev 125635)
@@ -28,7 +28,7 @@
 import zc.zk
 
 def worker(app, global_conf, zookeeper, path, loggers=None, address=':0',
-           threads=None, backdoor=False, run=True, **kw):
+           threads=None, backdoor=False, description=None, run=True, **kw):
     """Paste deploy server runner
     """
     if loggers:
@@ -61,6 +61,9 @@
         registration_data['backdoor'] = '127.0.0.1:%s' % bd.server_port
         worker.__bd = bd
 
+    if description:
+        registration_data['description'] = description
+
     zk.register_server(path+'/providers', worker.addr, **registration_data)
     worker.zk = zk
     worker.__zksettings = settings

Modified: zc.resumelb/trunk/src/zc/resumelb/zk.test
===================================================================
--- zc.resumelb/trunk/src/zc/resumelb/zk.test	2012-05-03 17:21:02 UTC (rev 125634)
+++ zc.resumelb/trunk/src/zc/resumelb/zk.test	2012-05-03 17:23:38 UTC (rev 125635)
@@ -65,6 +65,7 @@
     ...         zookeeper='zookeeper.example.com:2181', path='/test/lb/workers',
     ...         address='127.0.0.1:0', run=False, loggers='loggers',
     ...         resume_file='resume.mar',
+    ...         description='test',
     ...         )
     ...     configureLoggers.assert_called_with('loggers')
     ...     if basicConfig.called: print 'basicConfig'
@@ -101,6 +102,11 @@
     >>> bool(meta['ephemeralOwner'])
     True
 
+And provides some meta data:
+
+    >>> pprint(zk.get_properties('/test/lb/workers/providers/' + waddr))
+    {u'description': u'test', u'pid': 4195}
+
 Shutdown
 --------
 



More information about the checkins mailing list