[Dancer-users] Dancer and EV/thread-based servers
melo at simplicidade.org
Wed Jan 25 10:57:41 CET 2012
On Tue, Jan 24, 2012 at 10:27 PM, Nick Knutov <mail at knutov.com> wrote:
> the question may be not about Dancer itself, but what should I know to write
> Dancer' plugins and applications compatible with EV- and threads-based
I regularly use Dancer with EV-based servers (Twiggy using the EV
backend to AnyEvent and Feersum), I don't have any problems, but maybe
I'm missing what you mean by "compatible".
If you are asking if the plugins can use the EV capabilities during a
single request to start several calls to external network services,
collect responses and generate the result, the answer is yes. See the
metacpan web app for an example using Catalyst that should be
applicable to Dancer with little modification.
But if you're are looking for a way to process several requests at the
same time, for example processing a second request while the first is
waiting on some network protocol, then the answer is no, at least for
Dancer v1, don't know Dancer v2 yet. AFAIK, only Tatsumaki will allow
you to multiplex multiple HTTP requests on the same process.
But between Dancer requests, when the control returns to the EV core,
you can run other callbacks. So you can, for example, have a XMPP bot
(using AnyEvent::XMPP2) running in the same process as a Dancer app,
and interact with it, even to query Dancer internals and/or modify
configurations. The XMPP processing will occur between Dancer
You can also use AnyEvent timers with a Dancer app. Again, they will
be triggered between requests. Useful to collect stats on a Dancer app
and send them to a remote server.
I use those last two quite a lot actually.
xmpp:melo at simplicidade.org
mailto:melo at simplicidade.org
More information about the Dancer-users