forked from miyagawa/Corona
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename Plack::Server::Coro to Corona
- Loading branch information
Showing
10 changed files
with
141 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use lib "lib"; | ||
use Plack::Runner; | ||
|
||
my $runner = Plack::Runner->new(server => 'Corona', env => 'deployment'); | ||
$runner->parse_options(@ARGV); | ||
$runner->run; | ||
|
||
__END__ | ||
=head1 NAME | ||
corona - Corona launcher | ||
=head1 SYNOPSIS | ||
corona --listen :9090 | ||
Run C<plackup -h> for more options. | ||
=head1 SEE ALSO | ||
L<Corona> L<plackup> | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package Corona; | ||
use strict; | ||
use 5.008_001; | ||
our $VERSION = 0.1000; | ||
|
||
__END__ | ||
=head1 NAME | ||
Corona - Coro based PSGI web server | ||
=head1 SYNOPSIS | ||
plackup --server Corona | ||
=head1 DESCRIPTION | ||
Corona is a Coro based Plack web server. It uses L<Net::Server::Coro> | ||
under the hood, which means we have coroutines (threads) for each | ||
socket, active connections and a main loop. | ||
Because it's Coro based your web application can actually block with | ||
I/O wait as long as it yields when being blocked, to the other | ||
coroutine either explicitly with C<cede> or automatically (via Coro::* | ||
magic). | ||
# your web application | ||
use Coro::LWP; | ||
my $content = LWP::Simple::get($url); # this yields to other threads when IO blocks | ||
Corona also uses L<Coro::AIO> (and L<IO::AIO>) if available, to send | ||
the static filehandle using sendfile(2). | ||
The simple benchmark shows this server gives 2000 requests per second | ||
in the simple Hello World app, and 300 requests to serve 2MB photo | ||
files when used with AIO modules. Brilliantly fast. | ||
This web server sets C<psgi.multithread> env var on. | ||
=head1 AUTHOR | ||
Tatsuhiko Miyagawa | ||
=head1 LICENSE | ||
This module is licensed under the same terms as Perl itself. | ||
=head1 SEE ALSO | ||
L<Coro> L<Net::Server::Coro> L<Coro::AIO> | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package Plack::Handler::Corona; | ||
use strict; | ||
use Corona::Server; | ||
|
||
sub new { | ||
my $class = shift; | ||
bless { @_ }, $class; | ||
} | ||
|
||
sub run { | ||
my($self, $app) = @_; | ||
|
||
my $server = Corona::Server->new( | ||
host => $self->{host} || '*', | ||
user => $self->{user} || $>, | ||
group => $self->{group} || $), | ||
log_level => 1, | ||
); | ||
$server->{app} = $app; | ||
$server->run(port => $self->{port}); | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
Plack::Handler::Corona - Corona server adapter for Plack | ||
=head1 SYNOPSIS | ||
plackup -s Corona --port 9091 app.psgi | ||
=head1 SEE ALSO | ||
L<Corona> | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use strict; | ||
use Test::More tests => 1; | ||
|
||
BEGIN { use_ok 'Plack::Server::Coro' } | ||
BEGIN { use_ok 'Corona::Server' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use strict; | ||
use Test::More; | ||
use Plack::Test::Suite; | ||
|
||
Plack::Test::Suite->run_server_tests('Corona'); | ||
done_testing(); | ||
|