Antares Trader Blog

The universe at your fingertips

Rack and Comet with Ebb.

Saturday

Nov 22, 2008

1:50 pm

Have you read the Rack specs? In detail? Here's one I bet you missed. When a Rack server calls and app it gets back an array with the status, the headers and the body. The body is not just text, however, it is a Object that responds to :each by yielding text. So whats the big deal? Think about this. What if, instead of returning immediately from that :each call an object waited for some event and called the block sent to each in responce? With a little hacking we have all the makings of a Comet server already built into Rack.

The problem is not all Rack server are so nice about how they deal with delays in :each. Mongrel for example doesn't write anything to the line until it has a complete respnce ints greedy virtual paws. Ebb on the other hand is very happy to produce a chuncked responce and zip things off down the line while still waiting for each to yield its next juicy bit.

My hope in writing this is that someone will take this kernel of an Idea and write a Rack app that can be the backend for a Orbited Socket service or Bayeux. The Gist is posted below:

edit delete