Thanks for your reply, Sebastian.
After I sent my email, I figured that the drain callback must be the only way. I just had to brush off the Node.js memories and then it all made enough sense. I think it was just confusing because a lot of Mojolicious code can be written in a direct style without needing to use continuation passing, and the documentation didn’t quite make the drain event requirement clear to me, although it all makes more sense in hindsight. We’re in a slow process of trying to move the 20 year old Koha project away from CGI, so originally I was going to do a bare bones PSGI handler, but we’re starting to use Mojolicious for new parts of the project, so I thought I’d try that instead. While the continuation passing style might not be intuitive, it’ll be much nicer to have an asynchronous Mojolicious handler, so that one request for a large stream of data doesn’t totally tie up the backend server processes. I’m excited to play with Mojolicious more. And thanks for mentioning the async/await. That looks like a much more user-friendly alternative, although I think that we’ll wait until Mojo::Base doesn’t flag it as experimental. We also have a long tail of older Perl versions to support, unfortunately. Cheers, David Cook Software Engineer Prosentient Systems 72/330 Wattle St Ultimo, NSW 2007 Australia Office: 02 9212 0899 Online: 02 8005 0595 From: mojolicious@googlegroups.com <mojolicious@googlegroups.com> On Behalf Of Sebastian Riedel Sent: Friday, 23 October 2020 8:16 PM To: Mojolicious <mojolicious@googlegroups.com> Subject: [Mojolicious] Re: Ways of rendering a stream Typically, with a stream, you'd just write the HTTP headers, and then just start writing out your content. I don't understand why it's so challenging with Mojolicious. I figured finalizing the response headers would be what I needed, but now I have no idea. I'm not trying to do anything fancy. I'm just trying to read records from a database, and write them out to in a stream to the browser. I would think many people would have this same use case without doing anything too complicated in their web framework. The drain callback is the only way, because we use an event loop and non-blocking I/O. The whole thing could theoretically be wrapped in promises and then made to look blocking with async/await, but that doesn't really change how it works internally. -- sebastian -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com <mailto:mojolicious+unsubscr...@googlegroups.com> . To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/c4412264-2954-4f5b-a0ed-45f506d53df4n%40googlegroups.com <https://groups.google.com/d/msgid/mojolicious/c4412264-2954-4f5b-a0ed-45f506d53df4n%40googlegroups.com?utm_medium=email&utm_source=footer> . -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/06ff01d6ab31%249f0c29d0%24dd247d70%24%40prosentient.com.au.