MtPolicyd/Plugin/Stress.pm

filter: Statementstmt 55.1% 16 / 29 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 44.4% 20 / 45 CC 5 SCAR 29.5
CC
5
Cov
42%
run
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 19.1
« MtPolicyd/Request.pm ↑ Summary MtPolicyd/Client/Request.pm »
1 package Mail::MtPolicyd::Plugin::Stress;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '2.01'; # VERSION
7 # ABSTRACT: mtpolicyd plugin for postfix stress mode
8  
9 1 extends 'Mail::MtPolicyd::Plugin';
10  
11 1 with 'Mail::MtPolicyd::Plugin::Role::UserConfig' => {
12 'uc_attributes' => [ 'action' ],
13 };
14 1 with 'Mail::MtPolicyd::Plugin::Role::PluginChain';
15  
16 1 ▶use Mail::MtPolicyd::Plugin::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 1 has 'action' => ( is => 'rw', isa => 'Maybe[Str]' );
20  
21 sub run {
22 0 ▶ my ( $self, $r ) = @_;
Subroutine run: not called CC=5 SCAR=34.0
Pod documented
23 0 my $session = $r->session;
24 0 my $stress = $r->attr('stress');
25  
26 0 ▶ if( defined $stress && $stress eq 'yes' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stress and $stress eq "yes") 0 0 0
Condition0%0/3
defined $stress and $stress eq "yes"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $stress and $stress eq "yes"
defined $stress $stress eq "yes"
Truth table0%0/3
A and B
A= defined $stressB= $stress eq "yes"
ABresult
0X0
100
111
27 0 $self->log($r, 'MTA has stress feature turned on');
28  
29 0 my $action = $self->get_uc($session, 'action');
30 0 ▶ if( defined $action ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $action) 0 0 0
31 0 return Mail::MtPolicyd::Plugin::Result->new(
32 action => $action,
33 abort => 1,
34 );
35 }
36 0 ▶ if( defined $self->chain ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->chain) 0 0 0
37 0 my $chain_result = $self->chain->run( $r );
38 0 return( @{$chain_result->plugin_results} );
39 }
40 }
41  
42 0 return;
43 }
44  
45 1 __PACKAGE__->meta->make_immutable;
46  
47 1 1;
48  
49 __END__
50  
51 =pod
52  
53 =encoding UTF-8
54  
55 =head1 NAME
56  
57 Mail::MtPolicyd::Plugin::Stress - mtpolicyd plugin for postfix stress mode
58  
59 =head1 VERSION
60  
61 version 2.01
62  
63 =head1 DESCRIPTION
64  
65 Will return an action or execute futher plugins if postfix signals stress.
66  
67 See postfix STRESS_README.
68  
69 =head1 PARAMETERS
70  
71 An action must be specified:
72  
73 =over
74  
75 =item action (default: empty)
76  
77 The action to return when under stress.
78  
79 =item Plugin (default: empty)
80  
81 Execute this plugins when under stress.
82  
83 =back
84  
85 =head1 EXAMPLE: defer clients when under stress
86  
87 To defer clients under stress:
88  
89 <Plugin stress>
90 module = "Stress"
91 action = "defer please try again later"
92 </Plugin>
93  
94 This will return an defer action and execute no futher tests.
95  
96 You may want to do some whitelisting for preferred clients before this action.
97  
98 =head1 AUTHOR
99  
100 Markus Benning <ich@markusbenning.de>
101  
102 =head1 COPYRIGHT AND LICENSE
103  
104 This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.
105  
106 This is free software, licensed under:
107  
108 The GNU General Public License, Version 2, June 1991
109  
110 =cut
« MtPolicyd/Request.pm ↑ Summary MtPolicyd/Client/Request.pm »