Hi Alexander,
I haven't had a chance to implement streaming in Poet/Mason2 yet,
unfortunately. Patches are welcome. :)
Jon
On Oct 4, 2012, at 9:14 AM, Alexander wrote:
> Dear colleagues,
>
> I have rather massive SQL query results to be fed as CSV to the client. What
> I currently did is mounted a separate mount point in Plack and defined a
> streaming interface:
>
> package DF::Stream;
> [... use, constants, etc ... ]
> method csv($psgi_env, $responder) {
> my $writer = $responder->([ 200, [ 'Content-Type', 'text/csv' ] ]);
> [... some computation ....]
> while ($query->row) {
> $writer->write(join("\t", @$_),"\n");
> }
> $writer->close();
> }
> 1;
>
>
> [ later in app.psgi ]
>
> mount '/csv/' => sub {
> my $psgi_env = shift;
> $psgi_env->{'psgi.streaming'} or return [ 501,
> ['Content-Type','text/plain'], [] ];
>
> return sub {
> my $responder = shift;
>
> my $stream = new DF::Stream(conf => $conf->{data});
> $stream->csv($psgi_env, $responder);
> };
> };
>
>
>
> That works, but every time I need a new stream I have to introduce a new
> package and mount a new path.
>
>
> Is there a way to define a streaming interface as normal Mason components
> without Plack hacks? Any clue will be greatly appreciated.
>
> --
> Sincerely yours, Alexander Kuznetsov
> ------------------------------------------------------------------------------
> Don't let slow site performance ruin your business. Deploy New Relic APM
> Deploy New Relic app performance management and know exactly
> what is happening inside your Ruby, Python, PHP, Java, and .NET app
> Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> http://p.sf.net/sfu/newrelic-dev2dev_______________________________________________
> Mason-users mailing list
> Mason-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mason-users
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users