I've recently taken a liking to Go, and after an evening cruising through the Go Tour and various best practice docs, I wanted to put my knowledge to the test. Since web development is where I'm most at home, I decided to seek out a web framework. One of the first to catch my eye was Revel, which aims to be the "batteries included" web framework for Go. Being a fan of Python (the batteries included language), this felt unusually welcoming. In noticing that Revel has websocket support out of the box, I imagined this could provide an opportunity to do something interesting. However, anyone whose worked with raw websocket messaging knows it can get messy fast. In order to do anything substantial you'll find yourself re-creating similar features found in Socketio–which conveniently enough is made available via the go-socketio project. The final part of this puzzle is the focus of this month's brief blog post: combining revel and socketio into the same project, without running separate servers.

The gevent project has allowed us to transparently bolt on asynchronous functionality to otherwise synchronous python WSGI based web frameworks and servers. However, piecing together this puzzle for yourself may prove less than convenient as libraries and tutorials remain incomplete, skipping over many pertinent details. To remedy this confusion we'll put together a starter project combining gevent, django and socket.io to build a simple asynchronous application, pausing along the journey to discuss the relevant details. But first we'll detour to discuss event loops, in particular how gevent's implementation runs.