Skip to content

Latest commit

 

History

History
122 lines (81 loc) · 2.98 KB

README.pod

File metadata and controls

122 lines (81 loc) · 2.98 KB

NAME

This is a port of Mojo::IOLoop to AnyEvent event framework;

AnyEvent?

AnyEvent is the c00lest event loop available for Perl. You want to use it in your Mojo apps :)

Why should i care?

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.

CURRENT STATUS/LIMITATIONS:

* 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 :)

SYNOPSIS

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

INSTALLATION

To install this module, run the following commands:

perl Makefile.PL
make
make test
make install

SUPPORT AND DOCUMENTATION

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/

LICENSE AND COPYRIGHT

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.