Skip to content
Browse files

pod coverage test and fixes

  • Loading branch information...
1 parent a327b3e commit 3881f59a7c3e5d93648803054a471d2bb01f2a4f @stash committed Dec 20, 2010
Showing with 175 additions and 14 deletions.
  1. +1 −0 MANIFEST
  2. +18 −0 lib/Feersum.pm
  3. +28 −0 lib/Feersum/Connection.pm
  4. +12 −0 lib/Feersum/Connection/Handle.pm
  5. +35 −14 lib/Feersum/Runner.pm
  6. +19 −0 lib/Plack/Handler/Feersum.pm
  7. +62 −0 t/99-pod-coverage.t
View
1 MANIFEST
@@ -47,6 +47,7 @@ t/60-plack.t
t/61-plack-suite.t
t/62-plack-runner.t
t/63-plack-apps.t
+t/99-pod-coverage.t
t/Utils.pm
typemap
xt/50-psgi-simple-stress.t
View
18 lib/Feersum.pm
@@ -355,6 +355,12 @@ These are methods on the global Feersum singleton.
=over 4
+=item C<< new() >>
+
+=item C<< endjinn() >>
+
+Returns the C<Feersum> singleton. Takes no parameters.
+
=item C<< use_socket($sock) >>
Use the file-descriptor attached to a listen-socket to accept connections.
@@ -371,6 +377,10 @@ A reference to C<$sock> is kept as C<< Feersum->endjinn->{socket} >>.
Use the specified fileno to accept connections. May be used as an alternative
to C<use_socket>.
+=item C<< unlisten() >>
+
+Stop listening to the socket specified by use_socket or accept_on_fd.
+
=item C<< request_handler(sub { my $req = shift; ... }) >>
Sets the global request handler. Any previous handler is replaced.
@@ -383,6 +393,10 @@ be called B<only> after receiving the body in its entirety. The headers
rejected. The maximum size is hard coded to 2147483647 bytes (this may be
considered a bug).
+=item C<< psgi_request_handler(sub { my $env = shift; ... }) >>
+
+Like request_handler, but assigns a PSGI handler instead.
+
=item C<< read_timeout() >>
=item C<< read_timeout($duration) >>
@@ -437,6 +451,10 @@ waiting for a request entity body).
Any exceptions thrown in the handler will generate a warning and not
propagated.
+=item C<< set_server_name_and_port($host,$port) >>
+
+Override Feersum's notion of what SERVER_HOST and SERVER_PORT should be.
+
=back
=cut
View
28 lib/Feersum/Connection.pm
@@ -150,6 +150,34 @@ something interesting in its DESTROY/DEMOLISH method. For example, L<Guard>.
=back
+=begin comment
+
+=head2 Private and or Deprecated Methods
+
+=over 4
+
+=item C<< new() >>
+
+No-op. Feersum will create these objects internally.
+
+=item C<< $req->read_handle >>
+
+use psgi.input instead
+
+=item C<< $req->write_handle >>
+
+=item C<< $req->start_response(...) >>
+
+use start_streaming() or start_whole_response() instead
+
+=item C<< $req->initiate_streaming(...) >>
+
+use start_streaming() and its return value instead
+
+=back
+
+=end comment
+
=head1 AUTHOR
Jeremy Stashewsky, C<< stash@cpan.org >>
View
12 lib/Feersum/Connection/Handle.pm
@@ -154,6 +154,14 @@ to prevent a circular reference.
Methods in common to both types of handles.
+=begin comment
+
+=item C<< Feersum::Connection::Handle->new() >>
+
+Shouldn't be called directly; L<Feersum> will create these objects.
+
+=end comment
+
=over 4
=item C<< $h->response_guard($guard) >>
@@ -167,6 +175,10 @@ the response.
C<psgix.output.guard> is the PSGI-env extension that indicates this method.
+=item C<< $h->fileno >>
+
+Returns the file descriptor number for this connection.
+
=back
=head1 AUTHOR
View
49 lib/Feersum/Runner.pm
@@ -1,4 +1,5 @@
package Feersum::Runner;
+use warnings;
use strict;
use EV;
@@ -7,7 +8,15 @@ use Socket qw/SOMAXCONN/;
use POSIX ();
use Scalar::Util qw/weaken/;
-sub new { my $c = shift; bless {quiet => 1, @_},$c }
+{
+ my $INSTANCE;
+ sub new {
+ my $c = shift;
+ return $INSTANCE if $INSTANCE;
+ $INSTANCE = bless {quiet => 1, @_}, $c;
+ return $INSTANCE;
+ }
+}
sub _prepare {
my $self = shift;
@@ -61,12 +70,12 @@ sub run {
$self->{_quit} = EV::signal 'QUIT', sub { $self->quit };
- $self->pre_fork if $self->{pre_fork};
+ $self->_start_pre_fork if $self->{pre_fork};
EV::run;
$self->{quiet} or warn "Feersum [$$]: done\n";
}
-sub fork_another {
+sub _fork_another {
my ($self, $slot) = @_;
weaken $self;
@@ -92,18 +101,18 @@ sub fork_another {
EV::break(EV::BREAK_ALL) unless $self->{_n_kids};
return;
}
- $self->fork_another();
+ $self->_fork_another();
};
}
-sub pre_fork {
+sub _start_pre_fork {
my $self = shift;
POSIX::setsid();
$self->{_kids} = [];
$self->{_n_kids} = 0;
- $self->fork_another($_) for (1 .. $self->{pre_fork});
+ $self->_fork_another($_) for (1 .. $self->{pre_fork});
$self->{endjinn}->unlisten();
}
@@ -151,12 +160,17 @@ Feersum::Runner
Much like L<Plack::Runner>, but with far fewer options.
-=head1 ATTRIBUTES
-
-The following initialization options are available.
+=head1 METHODS
=over 4
+=item C<< Feersum::Runner->new(%params) >>
+
+Returns a Feersum::Runner singleton. Params are only applied for the first
+invocation.
+
+=over 8
+
=item listen
Listen on this TCP socket (C<host:port> format).
@@ -170,23 +184,30 @@ the C<run()> method).
=item quiet
-Don't be so noisy.
+Don't be so noisy. (default: on)
=item app_file
Load this filename as a native feersum app.
=back
-=head1 METHODS
-
-=over 4
-
=item C<< $runner->run($feersum_app) >>
Run Feersum with the specified app code reference. Note that this is not a
PSGI app, but a native Feersum app.
+=item C<< $runner->assign_request_handler($subref) >>
+
+For sub-classes to override, assigns an app handler. (e.g.
+L<Plack::Handler::Feersum>). By default, this assigns a Feersum-native (and
+not PSGI) handler.
+
+=item C<< $runner->quit() >>
+
+Initiate a graceful shutdown. A signal handler for SIGQUIT will call this
+method.
+
=back
=head1 AUTHOR
View
19 lib/Plack/Handler/Feersum.pm
@@ -31,11 +31,30 @@ This is a stub module that allows Feersum to be loaded up under C<plackup> and
other Plack tools. Set C<< $ENV{PLACK_SERVER} >> to 'Feersum' or use the -s
parameter to plackup to use Feersum under Plack.
+=head2 Experimental Features
+
A C<--pre-fork=N> parameter can be specified to put feersum into pre-forked
mode where N is the number of child processes. The C<--preload-app> parameter
that L<Starlet> supports isn't supported yet. The fork is run immediately
after startup and after the app is loaded (i.e. in the C<run()> method).
+=head1 METHODS
+
+=over 4
+
+=item C<< assign_request_handler($app) >>
+
+Assigns the PSGI request handler to Feersum.
+
+Also sets up a SIGTERM handler to call the C<quit()> method so that
+L<Plack::Loader::Restarter> will work.
+
+=back
+
+=head1 SEE ALSO
+
+Most of the functionality is in L<Feersum::Runner> (the base class)
+
=head1 AUTHOR
Jeremy Stashewsky, C<< stash@cpan.org >>
View
62 t/99-pod-coverage.t
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+
+# Ensure pod coverage in your distribution
+use strict;
+BEGIN {
+ $| = 1;
+ $^W = 1;
+}
+
+my @MODULES = (
+ 'Test::Pod::Coverage 1.08',
+ 'File::Spec',
+);
+
+# Don't run tests during end-user installs
+use Test::More;
+plan( skip_all => 'Author tests not required for installation' )
+ unless ( $ENV{RELEASE_TESTING} );
+
+# Load the testing modules
+foreach my $MODULE ( @MODULES ) {
+ eval "use $MODULE";
+ if ( $@ ) {
+ $ENV{RELEASE_TESTING}
+ ? die( "Failed to load required release-testing module $MODULE" )
+ : plan( skip_all => "$MODULE not available for testing" );
+ }
+}
+
+my %poded = (
+ 'Feersum::Connection::Handle' => {
+ pod_from => 'blib/lib/Feersum/Connection/Handle.pm',
+ },
+ 'Feersum::Connection::Writer' => {
+ pod_from => 'blib/lib/Feersum/Connection/Handle.pm',
+ },
+ 'Feersum::Connection::Reader' => {
+ pod_from => 'blib/lib/Feersum/Connection/Handle.pm',
+ },
+ 'Feersum::Connection' => {
+ pod_from => 'blib/lib/Feersum/Connection.pm',
+ },
+ 'Feersum::Runner' => {
+ pod_from => 'blib/lib/Feersum/Runner.pm',
+ },
+ 'Feersum' => {
+ pod_from => 'blib/lib/Feersum.pm',
+ },
+ 'Plack::Handler::Feersum' => {
+ pod_from => 'blib/lib/Plack/Handler/Feersum.pm',
+ },
+ 'feersum' => {
+ pod_from => 'blib/script/feersum',
+ },
+);
+plan tests => scalar keys %poded;
+while (my ($mod, $params) = each %poded) {
+ $params->{pod_from} = File::Spec->catfile(split('/',$params->{pod_from}));
+ pod_coverage_ok($mod, $params);
+}
+
+1;

0 comments on commit 3881f59

Please sign in to comment.
Something went wrong with that request. Please try again.