This is a port of Mojo::IOLoop to AnyEvent event framework;
AnyEvent is the c00lest event loop available for Perl. You want to use it in your Mojo apps :)
Because you want (maybe you don't even know) to use all those goodies that come with AnyEvent (TLS, IPv6 support, lots of modules) in your Mojolicious webapp.
If you're programming highly concurrent applications using AnyEvent and you have a feeling that there is no http server/client worth including in your app, think again. Mojolicious has it all. Just
use AnyEvent::Mojolicious::IOLoop;
and you can now use great HTTP client and server implementation fully supporting IPv6, HTTP/1.1 and TLS.
* Mojo::IOLoop emulation via AnyEvent::Mojolicious::IOLoop: mostly works, some minor issues
* Mojo::Server::Daemon: works
* Mojo::Client works, but not all client tests succeed
* TLS support is not 100% finished, but mostly works :)
Put the following in myapp.pl:
#!/usr/bin/perl
use strict;
use warnings;
use Mojolicious::Lite;
get '/' => sub {
my ($self) = @_;
$self->render(data => "hello stranger from " . $self->tx->remote_address);
};
# some AnyEvent stuff!
get '/ae' => sub {
my $self = shift;
# AnyEvent and AE are already loaded...
my $delay = rand(1.3);
# delay response using AnyEvent timer:
my $t = AnyEvent->timer(
after => $delay,
cb => sub {
$self->render_data("Delayed response ($delay) by AnyEvent");
},
);
# the same with AE api:
# my $t = AE::timer(
# $delay, 0,
# sub {
# $self->render_data("Delayed response ($delay) by AnyEvent");
# }
# );
# save timer to stash
$self->stash(timer => $t);
};
# Start the Mojolicious command system
app->start;
Just start your webapplication with daemon_anyevent argument instead daemon:
$ ./myapp.pl daemon_anyevent
To install this module, run the following commands:
perl Makefile.PL
make
make test
make install
After installing, you can find documentation for this module with the perldoc command.
perldoc AnyEvent::Mojolicious
You can also look for information at:
RT, CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-Mojolicious
AnnoCPAN, Annotated CPAN documentation
http://annocpan.org/dist/AnyEvent-Mojolicious
CPAN Ratings
http://cpanratings.perl.org/d/AnyEvent-Mojolicious
Search CPAN
http://search.cpan.org/dist/AnyEvent-Mojolicious/
Copyright (C) 2011 "Brane F. Gracnar"
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.