Skip to content

Commit

Permalink
rename Plack::Server::Coro to Corona
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Mar 11, 2010
1 parent dfc1b65 commit 2e4b3b9
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 95 deletions.
5 changes: 4 additions & 1 deletion Changes
@@ -1,4 +1,7 @@
Revision history for Perl extension Plack::Server::Coro
Revision history for Perl extension Corona

0.100
- Renamed the software as 'Corona'

0.02 Sat Oct 24 01:27:12 PDT 2009
- Added psgi.streaming interface
Expand Down
9 changes: 5 additions & 4 deletions Makefile.PL
@@ -1,11 +1,12 @@
use inc::Module::Install;
name 'Plack-Server-Coro';
all_from 'lib/Plack/Server/Coro.pm';
readme_from 'lib/Plack/Server/Coro.pm';
name 'Corona';
all_from 'lib/Corona.pm';
readme_from 'lib/Corona.pm';
requires 'Coro';
requires 'Net::Server::Coro', 0.5;
requires 'Plack';
requires 'Plack', 0.99;
build_requires 'Test::More';
install_script 'bin/corona';
use_test_base;
auto_include_deps;
author_tests('xt');
Expand Down
10 changes: 5 additions & 5 deletions README
@@ -1,11 +1,11 @@
NAME
Plack::Server::Coro - Coro cooperative multithread web server
Corona - Coro based PSGI web server

SYNOPSIS
plackup --server Coro
plackup --server Corona

DESCRIPTION
This is a Coro based Plack web server. It uses Net::Server::Coro under
Corona is a Coro based Plack web server. It uses Net::Server::Coro under
the hood, which means we have coroutines (threads) for each socket,
active connections and a main loop.

Expand All @@ -15,9 +15,9 @@ DESCRIPTION

# your web application
use Coro::LWP;
my $content = LWP::Simple:;get($url); # this yields to other threads when IO blocks
my $content = LWP::Simple::get($url); # this yields to other threads when IO blocks

This server also uses Coro::AIO (and IO::AIO) if available, to send the
Corona also uses Coro::AIO (and IO::AIO) if available, to send the
static filehandle using sendfile(2).

The simple benchmark shows this server gives 2000 requests per second in
Expand Down
26 changes: 26 additions & 0 deletions bin/corona
@@ -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
52 changes: 52 additions & 0 deletions lib/Corona.pm
@@ -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
74 changes: 2 additions & 72 deletions lib/Plack/Server/Coro.pm → lib/Corona/Server.pm
@@ -1,31 +1,9 @@
package Plack::Server::Coro;
package Corona::Server;
use strict;
use 5.008_001;
our $VERSION = "0.02";

use Plack::Util;

sub new {
my $class = shift;
bless { @_ }, $class;
}

sub run {
my($self, $app) = @_;

my $server = Plack::Server::Coro::Server->new(
host => $self->{host} || '*',
user => $self->{user} || $>,
group => $self->{group} || $),
log_level => 1,
);
$server->{app} = $app;
$server->run(port => $self->{port});
}


package Plack::Server::Coro::Server;
use base qw( Net::Server::Coro );
use Plack::Util;

use constant HAS_AIO => !$ENV{PLACK_NO_SENDFILE} && eval "use Coro::AIO; 1";

Expand Down Expand Up @@ -126,54 +104,6 @@ sub _write_response {
$rouse_cb->() if $rouse_cb;
}

package Plack::Server::Coro;

1;

__END__
=head1 NAME
Plack::Server::Coro - Coro cooperative multithread web server
=head1 SYNOPSIS
plackup --server Coro
=head1 DESCRIPTION
This 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
This server 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
39 changes: 39 additions & 0 deletions lib/Plack/Handler/Corona.pm
@@ -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
2 changes: 1 addition & 1 deletion t/00_compile.t
@@ -1,4 +1,4 @@
use strict;
use Test::More tests => 1;

BEGIN { use_ok 'Plack::Server::Coro' }
BEGIN { use_ok 'Corona::Server' }
12 changes: 0 additions & 12 deletions t/coro.t

This file was deleted.

7 changes: 7 additions & 0 deletions t/corona.t
@@ -0,0 +1,7 @@
use strict;
use Test::More;
use Plack::Test::Suite;

Plack::Test::Suite->run_server_tests('Corona');
done_testing();

0 comments on commit 2e4b3b9

Please sign in to comment.