Commit 5f8f0a50 by PotatoGim

mojolicious: Per-Request-Stash with AnyEvent

An Example for Multiple HTTP requests asynchronously and per-request-stash on one Mojolicious request with AnyEvent Signed-off-by: PotatoGim's avatarJi-Hyeon Gim <potatogim@potatogim.net>
parent 4a9e525c
......@@ -2,7 +2,8 @@
#===========================================================================
# FILE: per_req_stash_with_async.pl
# USAGE: ./test.pl
# DESCRIPTION: Example for Per-Request-Stash with Async-way in Mojo.
# DESCRIPTION: An Example for Multiple HTTP requests asynchronously and
# Per-Request-Stash on one Mojolicious request with AnyEvent
# VERSION: 0.1
# OPTIONS: ---
# NOTES: ---
......@@ -49,9 +50,9 @@ hook after_build_tx => sub {
$req->unsubscribe('progress');
$PER_REQ_STASH{$rid} = time;
$PRS{$rid} = time;
print "PER_REQ_STASH: ${\Dumper(\%PER_REQ_STASH)}\n";
print "- PER-REQUEST-STASH: ${\Dumper(\%PRS)}\n";
}
);
};
......@@ -79,9 +80,9 @@ hook after_dispatch => sub {
$c->res->headers->remove('X-RID');
delete($PER_REQ_STASH{$rid});
delete($PRS{$rid});
print "- PER_REQ_STASH: ${\Dumper(\%PER_REQ_STASH)}\n";
print "- PER-REQUEST-STASH: ${\Dumper(\%PRS)}\n";
};
get '/' => sub {
......@@ -91,7 +92,7 @@ get '/' => sub {
$condvar->begin(
sub {
print "\nAll requests has done!\n";
print "\nAll requests have done!\n";
$condvar->send();
}
);
......@@ -145,7 +146,7 @@ app->start;
=head1 NAME
per_req_stash_with_async.pl - Example for Per-Request-Stash with Async-way in Mojo.
per_req_stash_with_async.pl - An Example for Multiple HTTP requests asynchronously and Per-Request-Stash in one Mojolicious request with AnyEvent
=head1 SYNOPSIS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment