Skip to content

Instantly share code, notes, and snippets.

@jberger
Forked from preaction/named-delay.pl
Last active September 8, 2016 03:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jberger/38237c4a8d361feaa1be2e59060b4eda to your computer and use it in GitHub Desktop.
Save jberger/38237c4a8d361feaa1be2e59060b4eda to your computer and use it in GitHub Desktop.
use Mojolicious::Lite;
get '/' => sub {
my ( $c ) = @_;
$c->delay(
sub {
my ( $delay ) = @_;
say "Fetching Google";
$delay->pass('google');
$c->ua->get( 'http://google.com', $delay->begin );
say "Fetching Yahoo";
$delay->pass('yahoo');
$c->ua->get( 'http://yahoo.com', $delay->begin );
},
sub {
my ( $delay, %args ) = @_;
# do something with transactions by name ...
},
);
};
app->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment