[Catalyst] "Streamed" content delivery?!

Heiko Jansen heiko_jansen at web.de
Mon Aug 4 21:04:56 BST 2008

Dear Catalystians.

I have a question on how content generation and delivery works in Catalyst.

I'll probably have to implement a metasearch / federated search component for an app build with Catalyst.
The user submits a request containing a list of databases and a query. For each database the query has to be transformed to the query syntax of the respective db and is then submitted via one of many connection methods (SQL, HTTP, ...). The result received is then transformed to a common format, which gets cached and is used to generate output to the user (TT2 templates).

Accessing the databases sequentially is not an option because of greatly differing and probably quite long response times.

As far as I understand it, the usual way would be to implement a custom Model for the search.
I can think of two implementation strategies:
a) A method in the Model is called with all database names; one thread per database is started performing query transformation, connection and result parsing; as soon as the threads are started the main method returns, handing back sth like a thread queue or one or more sockets to the Controller; the controller loops over the pipelines and whenever it received complete answer processes a template (fragment) with that data structure
b) A thread is started in the controller for every database, in which a method in a Model is called that handles one database; the thread works like the one above but also processes the template and sends the final result to the Controller who sends it to the client.

I'd probably go for method a) because I could implement the Model method as a rather simple wrapper which in fact connects to a different server which does the heavy lifting. On the other hand method a) would mean that template processing would happen sequentially while in method b) this also could be done in parallel.

But no matter which one I choose the main question is this: 
Can I send data to the client incremetally (or you could say: as a stream) with catalyst? 
I want to send (using HTTP/1.0 without content-length header) the start of the html page when I receive the request; then send out a block for every databases result and finally (after the last db or a search timeout) a page footer. 
I'm a novice regarding catalyst and have so far only seen code examples where all output generation is done as a whole at the end of the requests lifecycle and I'd be very happy if you could tell where to look for examples or documentation concerning my needs.

Thx in advance
Schon gehört? Bei WEB.DE gibt' s viele kostenlose Spiele:

More information about the Catalyst mailing list