Skip to main content

RestMQ routing table for PerlMQ

[Update 2011-12-11] After several months of preparation to build this app I'm regretfully abandoning the effort. a) the mojo guys; b) since I've decided to concentrate on Python... RestMQ will have to do because there is no sense in rewriting the code for TornadoWeb. Good luck to us all.

As the project continues this article is going to convert the routing table from the RestMQ app to the PerlMQ version. The RestMQ snippet for the routing table associates the URL to a particular event handler in a list form. The Mojolicious version does not. In the Mojo version the URL and the handler's signature are declared at once.

Here is the RestMQ routing table:

(r"/", IndexHandler),
(r"/q/(.*)", RestQueueHandler),
(r"/c/(.*)", CometQueueHandler),
(r"/p/(.*)", PolicyQueueHandler),
(r"/j/(.*)", JobQueueInfoHandler),
(r"/stats/(.*)", StatusHandler),
(r"/queue", QueueHandler),
(r"/control/(.*)", QueueControlHandler),
(r"/ws/(.*)", WebSocketQueueHandler),


Converting this to the perl version is going to be pretty easy. Most of the handlers have support for get/post and some support delete. These are the rest commands and the actual route or call of the individual function methods are handled by the frameworks. As to whether the list version is better than the inline version is to be debated.


In my opinion the list version is better because it's concise. The code is self documented right here. However, Mojolicious has an interesting feature is that it can export the routing table as part of the command line interface. This allows the user to verify the work before forcing the programmer to re-review the code from scratch.

The Mojolicious analog of the route table above is as follows:
# ----------------> (r"/", IndexHandler),
# http://localhost/?[queue=...]&[callback=...]
get '/' => sub { ... }
# http://localhost/
# queue=
# [msg=...]
# [value=...]
post '/' => sub { ... }

# ----------------> (r"/q/(.*)", RestQueueHandler),
# http://localhost/?[callback=...]
get '/q' => sub { ... }
# http://localhost/<queue>?[callback=...]
# [msg=...]
# [value=...]
post '/q/:queue => sub { ... }

# http://localhost/<queue>?[callback=...]
delete '/q/:queue' => sub { ... }

# ----------------> (r"/queue", QueueHandler),
# http://localhost/queue
get '/queue' => sub { ... }

# http://localhost/queue
# [msg=...]
# [body=...]
post '/queue' => sub { ... }

# ----------------> (r"/c/(.*)", CometQueueHandler),
get '/c/:queue' => sub { ... }

# ----------------> (r"/p/(.*)", PolicyQueueHandler),
# http://localhost/p/<queue>
get '/p/:queue' => sub { ... }

# http://localhost/p/<queue>
# [policy=...]
# [callback=...]
post '/p/:queue' => sub { ... }

# ----------------> (r"/j/(.*)", JobQueueInfoHandler),
# http://localhost/j/<queue>
get '/j/:queue' => sub { ... }

# ----------------> (r"/stats/(.*)", StatusHandler),
# http://localhost/stats/<queue>
get '/stats/:queue' => sub { ... }

# ----------------> (r"/control/(.*)", QueueControlHandler),
# http://localhost/control/[queue]
get '/control/:queue' => sub { ... }

# http://localhost/control/<queue>
# [status=(start|stop) ]
post '/control/:queue' => sub { ... }

# ----------------> (r"/ws/(.*)", WebSocketQueueHandler),
# I'm not sure how this is going to translate yet
#get '' => sub { ... }
#post '' => sub { ... }
#delete '' => sub { ... }

PS: One thing that is missing from this project so far... is the actual layout of the folders and and sort of installation program. For the moment I have deferred that step because I'm still trying to decide whether or not to integrate this into the Mojo project (If they will take me).

Comments

Popular posts from this blog

Entry level cost for CoreOS+Tectonic

CoreOS and Tectonic start their pricing at 10 servers. Managed CoreOS starts at $1000 per month for those first 10 servers and Tectonic is $5000 for the same 10 servers. Annualized that is $85K or at least one employee depending on your market. As a single employee company I'd rather hire the employee. Specially since I only have 3 servers.

The pricing is biased toward the largest servers with the largest capacities; my dual core 32GB i5 IntelNuc can never be mistaken for a 96-CPU dual or quad core DELL

If CoreOS does not figure out a different barrier of entry they are going to follow the Borland path to obscurity.

UPDATE 2017-10-30: With gratitude the CoreOS team has provided updated information on their pricing, however, I stand by my conclusion that the effective cost is lower when you deploy monster machines. The cost per node of my 1 CPU Intel NUC is the same as a 96 CPU server when you get beyond 10 nodes. I'll also reiterate that while my pricing notes are not currently…

eGalax touch on default Ubuntu 14.04.2 LTS

I have not had success with the touch drivers as yet.  The touch works and evtest also seems to report events, however, I have noticed that the button click is not working and no matter what I do xinput refuses to configure the buttons correctly.  When I downgraded to ubuntu 10.04 LTS everything sort of worked... there must have been something in the kermel as 10.04 was in the 2.6 kernel and 4.04 is in the 3.x branch.

One thing ... all of the documentation pointed to the wrong website or one in Taiwanese. I was finally able to locate the drivers again: http://www.eeti.com.tw/drivers_Linux.html (it would have been nice if they provided the install instructions in text rather than PDF)
Please open the document "EETI_eGTouch_Programming_Guide" under the Guide directory, and follow the Guidline to install driver.
download the appropriate versionunzip the fileread the programming manual And from that I'm distilling to the following: execute the setup.sh answer all of the questio…

Prometheus vs Bosun

In conclusion... while Bosun(B) is still not the ideal monitoring system neither is Prometheus(P).

TL;DR;

I am running Bosun in a Docker container hosted on CoreOS. Fleet service/unit files keep it running. However in once case I have experienced at least one severe crash as a result of a disk full condition. That it is implemented as part golang, java and python is an annoyance. The MIT license is about the only good thing.

I am trying to integrate Prometheus into my pipeline but losing steam fast. The Prometheus design seems to desire that you integrate your own cache inside your application and then allow the server to scrape the data, however, if the interval between scrapes is shorter than the longest transient session of your application then you need a gateway. A place to shuttle your data that will be a little more persistent.

(1) storing the data in my application might get me started more quickly
(2) getting the server to pull the data might be more secure
(3) using a push g…