Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

pod coverage test and fixes

  • Loading branch information...
commit 3881f59a7c3e5d93648803054a471d2bb01f2a4f 1 parent a327b3e
Jeremy Stashewsky authored
1  MANIFEST
@@ -47,6 +47,7 @@ t/60-plack.t
47 47 t/61-plack-suite.t
48 48 t/62-plack-runner.t
49 49 t/63-plack-apps.t
  50 +t/99-pod-coverage.t
50 51 t/Utils.pm
51 52 typemap
52 53 xt/50-psgi-simple-stress.t
18 lib/Feersum.pm
@@ -355,6 +355,12 @@ These are methods on the global Feersum singleton.
355 355
356 356 =over 4
357 357
  358 +=item C<< new() >>
  359 +
  360 +=item C<< endjinn() >>
  361 +
  362 +Returns the C<Feersum> singleton. Takes no parameters.
  363 +
358 364 =item C<< use_socket($sock) >>
359 365
360 366 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} >>.
371 377 Use the specified fileno to accept connections. May be used as an alternative
372 378 to C<use_socket>.
373 379
  380 +=item C<< unlisten() >>
  381 +
  382 +Stop listening to the socket specified by use_socket or accept_on_fd.
  383 +
374 384 =item C<< request_handler(sub { my $req = shift; ... }) >>
375 385
376 386 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
383 393 rejected. The maximum size is hard coded to 2147483647 bytes (this may be
384 394 considered a bug).
385 395
  396 +=item C<< psgi_request_handler(sub { my $env = shift; ... }) >>
  397 +
  398 +Like request_handler, but assigns a PSGI handler instead.
  399 +
386 400 =item C<< read_timeout() >>
387 401
388 402 =item C<< read_timeout($duration) >>
@@ -437,6 +451,10 @@ waiting for a request entity body).
437 451 Any exceptions thrown in the handler will generate a warning and not
438 452 propagated.
439 453
  454 +=item C<< set_server_name_and_port($host,$port) >>
  455 +
  456 +Override Feersum's notion of what SERVER_HOST and SERVER_PORT should be.
  457 +
440 458 =back
441 459
442 460 =cut
28 lib/Feersum/Connection.pm
@@ -150,6 +150,34 @@ something interesting in its DESTROY/DEMOLISH method. For example, L<Guard>.
150 150
151 151 =back
152 152
  153 +=begin comment
  154 +
  155 +=head2 Private and or Deprecated Methods
  156 +
  157 +=over 4
  158 +
  159 +=item C<< new() >>
  160 +
  161 +No-op. Feersum will create these objects internally.
  162 +
  163 +=item C<< $req->read_handle >>
  164 +
  165 +use psgi.input instead
  166 +
  167 +=item C<< $req->write_handle >>
  168 +
  169 +=item C<< $req->start_response(...) >>
  170 +
  171 +use start_streaming() or start_whole_response() instead
  172 +
  173 +=item C<< $req->initiate_streaming(...) >>
  174 +
  175 +use start_streaming() and its return value instead
  176 +
  177 +=back
  178 +
  179 +=end comment
  180 +
153 181 =head1 AUTHOR
154 182
155 183 Jeremy Stashewsky, C<< stash@cpan.org >>
12 lib/Feersum/Connection/Handle.pm
@@ -154,6 +154,14 @@ to prevent a circular reference.
154 154
155 155 Methods in common to both types of handles.
156 156
  157 +=begin comment
  158 +
  159 +=item C<< Feersum::Connection::Handle->new() >>
  160 +
  161 +Shouldn't be called directly; L<Feersum> will create these objects.
  162 +
  163 +=end comment
  164 +
157 165 =over 4
158 166
159 167 =item C<< $h->response_guard($guard) >>
@@ -167,6 +175,10 @@ the response.
167 175
168 176 C<psgix.output.guard> is the PSGI-env extension that indicates this method.
169 177
  178 +=item C<< $h->fileno >>
  179 +
  180 +Returns the file descriptor number for this connection.
  181 +
170 182 =back
171 183
172 184 =head1 AUTHOR
49 lib/Feersum/Runner.pm
... ... @@ -1,4 +1,5 @@
1 1 package Feersum::Runner;
  2 +use warnings;
2 3 use strict;
3 4
4 5 use EV;
@@ -7,7 +8,15 @@ use Socket qw/SOMAXCONN/;
7 8 use POSIX ();
8 9 use Scalar::Util qw/weaken/;
9 10
10   -sub new { my $c = shift; bless {quiet => 1, @_},$c }
  11 +{
  12 + my $INSTANCE;
  13 + sub new {
  14 + my $c = shift;
  15 + return $INSTANCE if $INSTANCE;
  16 + $INSTANCE = bless {quiet => 1, @_}, $c;
  17 + return $INSTANCE;
  18 + }
  19 +}
11 20
12 21 sub _prepare {
13 22 my $self = shift;
@@ -61,12 +70,12 @@ sub run {
61 70
62 71 $self->{_quit} = EV::signal 'QUIT', sub { $self->quit };
63 72
64   - $self->pre_fork if $self->{pre_fork};
  73 + $self->_start_pre_fork if $self->{pre_fork};
65 74 EV::run;
66 75 $self->{quiet} or warn "Feersum [$$]: done\n";
67 76 }
68 77
69   -sub fork_another {
  78 +sub _fork_another {
70 79 my ($self, $slot) = @_;
71 80 weaken $self;
72 81
@@ -92,18 +101,18 @@ sub fork_another {
92 101 EV::break(EV::BREAK_ALL) unless $self->{_n_kids};
93 102 return;
94 103 }
95   - $self->fork_another();
  104 + $self->_fork_another();
96 105 };
97 106 }
98 107
99   -sub pre_fork {
  108 +sub _start_pre_fork {
100 109 my $self = shift;
101 110
102 111 POSIX::setsid();
103 112
104 113 $self->{_kids} = [];
105 114 $self->{_n_kids} = 0;
106   - $self->fork_another($_) for (1 .. $self->{pre_fork});
  115 + $self->_fork_another($_) for (1 .. $self->{pre_fork});
107 116
108 117 $self->{endjinn}->unlisten();
109 118 }
@@ -151,12 +160,17 @@ Feersum::Runner
151 160
152 161 Much like L<Plack::Runner>, but with far fewer options.
153 162
154   -=head1 ATTRIBUTES
155   -
156   -The following initialization options are available.
  163 +=head1 METHODS
157 164
158 165 =over 4
159 166
  167 +=item C<< Feersum::Runner->new(%params) >>
  168 +
  169 +Returns a Feersum::Runner singleton. Params are only applied for the first
  170 +invocation.
  171 +
  172 +=over 8
  173 +
160 174 =item listen
161 175
162 176 Listen on this TCP socket (C<host:port> format).
@@ -170,7 +184,7 @@ the C<run()> method).
170 184
171 185 =item quiet
172 186
173   -Don't be so noisy.
  187 +Don't be so noisy. (default: on)
174 188
175 189 =item app_file
176 190
@@ -178,15 +192,22 @@ Load this filename as a native feersum app.
178 192
179 193 =back
180 194
181   -=head1 METHODS
182   -
183   -=over 4
184   -
185 195 =item C<< $runner->run($feersum_app) >>
186 196
187 197 Run Feersum with the specified app code reference. Note that this is not a
188 198 PSGI app, but a native Feersum app.
189 199
  200 +=item C<< $runner->assign_request_handler($subref) >>
  201 +
  202 +For sub-classes to override, assigns an app handler. (e.g.
  203 +L<Plack::Handler::Feersum>). By default, this assigns a Feersum-native (and
  204 +not PSGI) handler.
  205 +
  206 +=item C<< $runner->quit() >>
  207 +
  208 +Initiate a graceful shutdown. A signal handler for SIGQUIT will call this
  209 +method.
  210 +
190 211 =back
191 212
192 213 =head1 AUTHOR
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
31 31 other Plack tools. Set C<< $ENV{PLACK_SERVER} >> to 'Feersum' or use the -s
32 32 parameter to plackup to use Feersum under Plack.
33 33
  34 +=head2 Experimental Features
  35 +
34 36 A C<--pre-fork=N> parameter can be specified to put feersum into pre-forked
35 37 mode where N is the number of child processes. The C<--preload-app> parameter
36 38 that L<Starlet> supports isn't supported yet. The fork is run immediately
37 39 after startup and after the app is loaded (i.e. in the C<run()> method).
38 40
  41 +=head1 METHODS
  42 +
  43 +=over 4
  44 +
  45 +=item C<< assign_request_handler($app) >>
  46 +
  47 +Assigns the PSGI request handler to Feersum.
  48 +
  49 +Also sets up a SIGTERM handler to call the C<quit()> method so that
  50 +L<Plack::Loader::Restarter> will work.
  51 +
  52 +=back
  53 +
  54 +=head1 SEE ALSO
  55 +
  56 +Most of the functionality is in L<Feersum::Runner> (the base class)
  57 +
39 58 =head1 AUTHOR
40 59
41 60 Jeremy Stashewsky, C<< stash@cpan.org >>
62 t/99-pod-coverage.t
... ... @@ -0,0 +1,62 @@
  1 +#!/usr/bin/perl
  2 +
  3 +# Ensure pod coverage in your distribution
  4 +use strict;
  5 +BEGIN {
  6 + $| = 1;
  7 + $^W = 1;
  8 +}
  9 +
  10 +my @MODULES = (
  11 + 'Test::Pod::Coverage 1.08',
  12 + 'File::Spec',
  13 +);
  14 +
  15 +# Don't run tests during end-user installs
  16 +use Test::More;
  17 +plan( skip_all => 'Author tests not required for installation' )
  18 + unless ( $ENV{RELEASE_TESTING} );
  19 +
  20 +# Load the testing modules
  21 +foreach my $MODULE ( @MODULES ) {
  22 + eval "use $MODULE";
  23 + if ( $@ ) {
  24 + $ENV{RELEASE_TESTING}
  25 + ? die( "Failed to load required release-testing module $MODULE" )
  26 + : plan( skip_all => "$MODULE not available for testing" );
  27 + }
  28 +}
  29 +
  30 +my %poded = (
  31 + 'Feersum::Connection::Handle' => {
  32 + pod_from => 'blib/lib/Feersum/Connection/Handle.pm',
  33 + },
  34 + 'Feersum::Connection::Writer' => {
  35 + pod_from => 'blib/lib/Feersum/Connection/Handle.pm',
  36 + },
  37 + 'Feersum::Connection::Reader' => {
  38 + pod_from => 'blib/lib/Feersum/Connection/Handle.pm',
  39 + },
  40 + 'Feersum::Connection' => {
  41 + pod_from => 'blib/lib/Feersum/Connection.pm',
  42 + },
  43 + 'Feersum::Runner' => {
  44 + pod_from => 'blib/lib/Feersum/Runner.pm',
  45 + },
  46 + 'Feersum' => {
  47 + pod_from => 'blib/lib/Feersum.pm',
  48 + },
  49 + 'Plack::Handler::Feersum' => {
  50 + pod_from => 'blib/lib/Plack/Handler/Feersum.pm',
  51 + },
  52 + 'feersum' => {
  53 + pod_from => 'blib/script/feersum',
  54 + },
  55 +);
  56 +plan tests => scalar keys %poded;
  57 +while (my ($mod, $params) = each %poded) {
  58 + $params->{pod_from} = File::Spec->catfile(split('/',$params->{pod_from}));
  59 + pod_coverage_ok($mod, $params);
  60 +}
  61 +
  62 +1;

0 comments on commit 3881f59

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