Hookbox Client APIs

17 views
Skip to first unread message

Salman Haq

unread,
Apr 21, 2011, 9:31:23 AM4/21/11
to hoo...@googlegroups.com
I haven't kept up with the development of Hookbox lately so excuse me if
alternatives exists for what I am proposing.

I propose adding client APIs in multiple languages that wrap the details
of making the HTTP request to the hookbox server.

Here is an example of how it could be used in Python:

--------------------------------------------------------------
import hookbox
server_ip, server_port = '127.0.0.1', 50000
client = hookbox.Client(server_ip, server_port)
channel_data = { "channel_name": "foo", "security_token": "bar":
"payload": "baz" }
response = client.publish(channel_data)
if response[0] == True:
log.info("publish on channel foo succeeded.")
else:
log.info("publish on channel foo failed.")
----------------------------------------------------------------

Here is a snippet that shows how this client class would be implemented:

----------------------------------------------------------------
class Client (object):
""" Hookbox REST api client.
"""

def __init__ (self, server_ip, server_port):
""" Open an HTTP connection to the hookbox server.
"""
self.conn = httplib.HTTPConnection(server_ip, server_port)

def publish (self, data):
""" POST the channel data dictionary to the server.
"""
enc_data = urllib.urlencode(data)
headers = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
self.conn.request('POST', '/web/publish', enc_data, headers)
resp = self.conn.getresponse()
return resp.read()
----------------------------------------------------------------

I already have this almost ready to go for Python and can quickly add
something like this for Ruby and a few other languages. Additionally, in
Python I can add Twisted, Eventlet, and gevent versions of the client so
it can be integrated easily with whatever framework your Python
application happens to be using.

I have found it tremendously useful to work with. Let me know if other
developers have better ideas.

Thanks,
Salman

Rob Weiss

unread,
Apr 21, 2011, 9:35:01 AM4/21/11
to hoo...@googlegroups.com
Salman,
I am working on one using dojo's dojox.socket. We should have a library of these so people can choose which client they want to utilize based on their requirements.

I could use yours as a way to build up a hookbox farm.... neat idea!!

Thanks,
Rob.

Salman Haq

unread,
Apr 21, 2011, 10:06:57 AM4/21/11
to hoo...@googlegroups.com
Rob,

Where in the code tree were you planning on putting your work?

Are client implementations in the following languages and frameworks a good starting point then?

js/dojox
python
python/eventlet
python/gevent
ruby
ruby/eventmachine

Are there any developers interested in the following:

js/node.js
php?
scala?
java?
clojure?

For each of the above, are there preferred asynchronous IO frameworks?

Thanks,
Salman

Rob Weiss

unread,
Apr 21, 2011, 10:10:55 AM4/21/11
to hoo...@googlegroups.com
We probably should put the clients into a "clients" namespace since some of the clients are not JS, using the existing js dir makes little sense, but I am up for any suggestions.
Reply all
Reply to author
Forward
0 new messages