Coder Social home page Coder Social logo

anyevent-mojolicious's Introduction

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.

anyevent-mojolicious's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.