Skip to content
Browse files

Added a twistd plugin for running the RESTful rabbitmqctl service.

Improved Doxygen doc usage.
  • Loading branch information...
1 parent bc33d0f commit 84b762d7b2d67264f9248ccb3c433f916fe518fd @clemesha-ooi clemesha-ooi committed
Showing with 120 additions and 25 deletions.
  1. +1 −1 Doxyfile
  2. +16 −22 README
  3. 0 tests/__init__.py
  4. +1 −1 tests/test_service.py
  5. +50 −0 twisted/plugins/dropin.cache
  6. +51 −0 twisted/plugins/rest.py
  7. +1 −1 webui-example.tac.py
View
2 Doxyfile
@@ -582,7 +582,7 @@ INPUT_ENCODING = UTF-8
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-FILE_PATTERNS = *.py *.sh *.js *.html
+FILE_PATTERNS = *.py *.sh *.js *.html README
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
View
38 README
@@ -1,33 +1,30 @@
-===========================================================
-txrabbitmq - RabbitMQ's 'rabbitmqctl' as a Twisted Service.
-===========================================================
+@mainpage txrabbitmq - RabbitMQ's 'rabbitmqctl' as a Twisted Service.
-Overview
-========
+@section Overview
Implements RabbitMQ's 'rabbitmqctl' command line tool as a Twisted Service,
Expose this functionality over several protocols, most importantly: HTTP and AMQP.
-Install
-=======
+@section Install
The recommend way of using `txrabbit` is to create a `virtualenv` and
the install all dependencies with `pip` into the `virtualenv`
----------------------------------------------------------------
-
+@code
$ virtualenv --no-site-packages txrabbitmq_env
$ pip -E txrabbitmq_env install -U twotp orbited twisted simplejson stompservice
+@endcode
+@section Usage
-Usage
-=====
-
-Command / Data view
--------------------
- $ twistd -ny webui-example.tac.py
+RESTful Command / Data view
+---------------------------
+@code
+ $ twistd -n restrabbitmqctl
+@endcode
Push data from RabbitMQ
@@ -35,20 +32,17 @@ Push data from RabbitMQ
* From top-level dir run:
- $ twistd -ny webui-example.tac.py
+@code
+ $ twistd -n restrabbitmqctl
+@endcode
* Open 2 shells to dir `webui/push` and run:
+@code
$ python data_producer.py #first shell
$ orbited --config=rabbitmq.cfg #second shell
+@endcode
* Open ports 8000 and 9000, to see commands data and push, respectively
-
-
-Source on amoeba
-================
-amoeba.ucsd.edu
-
-
View
0 tests/__init__.py
No changes.
View
2 tests/test_service.py
@@ -21,7 +21,7 @@ class TestRabbitMQControlService(unittest.TestCase):
"""
def setUp(self):
- cookie = open(os.path.join(os.path.expanduser("~"), ".erlang.cookie.local")).read().strip()
+ cookie = readCookie()
nodeName = buildNodeName("test-txrabbitmq")
self.process = Process(nodeName, cookie)
self.service = RabbitMQControlService(self.process)
View
50 twisted/plugins/dropin.cache
@@ -0,0 +1,50 @@
+(dp1
+S'rest'
+p2
+ccopy_reg
+_reconstructor
+p3
+(ctwisted.plugin
+CachedDropin
+p4
+c__builtin__
+object
+p5
+NtRp6
+(dp7
+S'moduleName'
+p8
+S'twisted.plugins.rest'
+p9
+sS'description'
+p10
+S'\nRESTful interface to rabbitmqctl.\n\n@author Alex Clemesha <clemesha@ucsd.edu>\n@date 08/18/2009\n'
+p11
+sS'plugins'
+p12
+(lp13
+g3
+(ctwisted.plugin
+CachedPlugin
+p14
+g5
+NtRp15
+(dp16
+S'provided'
+p17
+(lp18
+ctwisted.plugin
+IPlugin
+p19
+actwisted.application.service
+IServiceMaker
+p20
+asS'dropin'
+p21
+g6
+sS'name'
+p22
+S'restrabbitmqctl'
+p23
+sg10
+Nsbasbs.
View
51 twisted/plugins/rest.py
@@ -0,0 +1,51 @@
+"""
+RESTful interface to rabbitmqctl.
+
+@author Alex Clemesha <clemesha@ucsd.edu>
+@date 08/18/2009
+"""
+import os
+import time
+
+from zope.interface import implements
+
+from twisted.plugin import IPlugin
+from twisted.application.service import IServiceMaker
+from twisted.python.usage import Options
+from twisted.application import internet, service
+from twisted.web import resource, server
+
+from twotp import Process, readCookie, buildNodeName
+
+from rabbitmqctl_service import RabbitMQControlService
+from webui.webui import RabbitMQControlWebUI
+
+class RESTRabbitmqctlOptions(Options):
+ optParameters = [
+ ['cookie', 'c', '', 'Erlang cookie value'],
+ ['nodename', 'n', 'restrabbitmqctl', 'Name of the node'],
+ ['port', 'p', '8888', 'HTTP port for the RESTful rabbitmqctl']
+ ]
+
+
+class RESTRabbitmqctlPlugin(object):
+ implements(IPlugin, IServiceMaker)
+
+ tapname = "restrabbitmqctl"
+ description = "RESTful interface to rabbitmqctl."
+ options = RESTRabbitmqctlOptions
+
+ def makeService(self, options):
+ cookie = options['cookie']
+ if not cookie:
+ cookie = readCookie()
+ print cookie
+ nodeName = buildNodeName(options['nodename'])
+ process = Process(nodeName, cookie)
+ rservice = RabbitMQControlService(process)
+ site = server.Site(resource.IResource(rservice))
+ srvc = internet.TCPServer(int(options['port']), site)
+ return srvc
+
+
+restrabbitmqctl = RESTRabbitmqctlPlugin()
View
2 webui-example.tac.py
@@ -12,7 +12,7 @@
PORT = 8888
WEBLOGPATH = "/tmp/txrabbitmqctl.web.%d.log" % int(time.time())
-cookie = open(os.path.join(os.path.expanduser("~"), ".erlang.cookie.local")).read().strip()
+cookie = readCookie()
nodeName = buildNodeName("twotp-rabbit")
process = Process(nodeName, cookie)
rservice = RabbitMQControlService(process)

0 comments on commit 84b762d

Please sign in to comment.
Something went wrong with that request. Please try again.