Gungho/Component/Throttle.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 36 CC 2 SCAR 11.5
CC
2
Cov
0%
send_request
6.0
feature_name
2.0
throttle
2.0
CRAP 3.1
1 # $Id: /mirror/gungho/lib/Gungho/Component/Throttle.pm 31302 2007-11-29T11:52:09.725591Z lestrrat $
2 #
3 # Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>
4  
5 package Gungho::Component::Throttle;
6 use strict;
7 use warnings;
8 use base qw(Gungho::Component);
9  
10 sub feature_name { 'Throttle' }
11  
12 sub throttle
13 {
14 my $c = shift;
15 $c->log->debug( $_[0]->url . " NOT throttled" );
16 return 1;
17 }
18  
19 sub send_request
20 {
21 my ($c, $request) = @_;
22  
23 if (! $request->notes('original_host') && ! $c->throttle($request)) {
24 $c->log->debug("[THROTTLE] Request " . $request->url . " (" . $request->id . ") was throttled");
25 $c->pushback_request($request);
26 return 0;
27 } else {
28 return $c->next::method($request);
29 }
30 }
31  
32 1;
33  
34 __END__