File Coverage

blib/lib/Apache/BalancerManager/Member.pm
Criterion Covered Total %
statement 9 9 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 3 3 100.0
total 18 18 100.0


line stmt bran cond sub pod time code
1             package Apache::BalancerManager::Member;
2             {
3             $Apache::BalancerManager::Member::VERSION = '0.001002';
4             }
5              
6             # ABSTRACT: ClientSide representation of Apache BalancerManager Member
7              
8 1     1   6 use Moo;
  1         2  
  1         9  
9              
10             has $_ => ( is => 'rw' ) for qw(
11             load_factor
12             lb_set
13             route
14             route_redirect
15             status
16             );
17              
18             has $_ => ( is => 'ro' ) for qw(
19             times_elected
20             location
21             );
22              
23             has $_ => (
24             is => 'ro',
25             coerce => sub {$_[0] =~ s/\s//g; $_[0]}
26             ) for qw(from to);
27              
28             has manager => (
29             is => 'ro',
30             required => 1,
31             weak_ref => 1,
32             handles => {
33             _balancer_name => 'name',
34             _nonce => 'nonce',
35             _url => 'url',
36             _get => '_get',
37             },
38             );
39              
40 1     1 1 8 sub disable { $_[0]->status(0) }
41 1     1 1 3121 sub enable { $_[0]->status(1) }
42              
43             sub update {
44 4     4 1 23240 my $self = shift;
45              
46 4         82 my $uri = URI->new($self->_url);
47 4 100       1172 $uri->query_form({
48             lf => $self->load_factor,
49             ls => $self->lb_set,
50             wr => $self->route,
51             rr => $self->route_redirect,
52             dw => ( $self->status ? 'Enable' : 'Disable' ),
53             w => $self->location,
54             b => $self->_balancer_name,
55             nonce => $self->_nonce,
56             });
57 4         1878 $self->_get($uri);
58             }
59              
60             1;
61              
62              
63             __END__