| 1 | package Lim::RPC::Transport; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use common::sense; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Scalar::Util qw(blessed weaken); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Log::Log4perl (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Lim (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =encoding utf8 | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | ... | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 VERSION | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | See L<Lim> for version. | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =cut | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 5 | our $VERSION = $Lim::VERSION; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | ... | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head2 new | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =cut | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=17.4
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 4 | my $this = shift; | |||||||||||||||||||||||||||
| 37 | 4 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||
| 38 | 4 | my %args = ( @_ ); | |||||||||||||||||||||||||||
| 39 | 4 | my $self = { | |||||||||||||||||||||||||||
| 40 | logger => Log::Log4perl->get_logger($class), | ||||||||||||||||||||||||||||
| 41 | __protocols => [] | ||||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||
| 43 | 4 | bless $self, $class; | |||||||||||||||||||||||||||
| 44 | 4 | weaken($self->{logger}); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 4 | ▶ | unless (blessed($args{server}) and $args{server}->isa('Lim::RPC::Server')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($args{"server"}) and $args{"server"}->isa("Lim::RPC::Server")
MC/DC0%0/2
builtin::blessed($args{"server"}) and $args{"server"}->isa("Lim::RPC::Server")
builtin::blessed($args{"server"})
$args{"server"}->isa("Lim::RPC::Server")
Truth table33%1/3
A and B
A= builtin::blessed($args{"server"})B= $args{"server"}->isa("Lim::RPC::Server")
| |||||||||||||||||||||||||||||
| 47 | 0 | confess __PACKAGE__, ': No server specified or invalid'; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 4 | $self->{__server} = $args{server}; | |||||||||||||||||||||||||||
| 50 | 4 | weaken($self->{__server}); | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | $self->Init(@_); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 4 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 4 | $self; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 4 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 59 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||
| 60 | 4 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 4 | $self->Destroy; | |||||||||||||||||||||||||||
| 63 | 4 | delete $self->{__protocols}; | |||||||||||||||||||||||||||
| 64 | 4 | delete $self->{__server}; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =head2 Init | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub Init { | ||||||||||||||||||||||||||
|
Subroutine
Init: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head2 Destroy | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub Destroy { | ||||||||||||||||||||||||||
|
Subroutine
Destroy: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head2 name | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | confess 'function name not overloaded'; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =head2 uri | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub uri { | ||||||||||||||||||||||||||
|
Subroutine
uri: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 0 | confess 'function uri not overloaded'; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =head2 add_protocol | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 4 | ▶ | sub add_protocol { | ||||||||||||||||||||||||||
|
Subroutine
add_protocol: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||
| 102 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 4 | foreach (@_) { | |||||||||||||||||||||||||||
| 105 | 4 | ▶ | unless (blessed($_) and $_->isa('Lim::RPC::Protocol')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($_) and $_->isa("Lim::RPC::Protocol")
MC/DC0%0/2
builtin::blessed($_) and $_->isa("Lim::RPC::Protocol")
builtin::blessed($_)
$_->isa("Lim::RPC::Protocol")
Truth table33%1/3
A and B
A= builtin::blessed($_)B= $_->isa("Lim::RPC::Protocol")
| |||||||||||||||||||||||||||||
| 106 | 0 | confess 'Argument is not a Lim::RPC::Protocol'; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | 4 | push(@{$self->{__protocols}}, @_); | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 4 | $self; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head2 protocols | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =cut | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 4 | ▶ | sub protocols { | ||||||||||||||||||||||||||
|
Subroutine
protocols: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 119 | 4 | @{$_[0]->{__protocols}}; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =head2 server | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =cut | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub server { | ||||||||||||||||||||||||||
|
Subroutine
server: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 127 | 0 | $_[0]->{__server}; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head2 host | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub host { | ||||||||||||||||||||||||||
|
Subroutine
host: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 135 | 0 | confess 'function host not overloaded'; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =head2 port | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =cut | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub port { | ||||||||||||||||||||||||||
|
Subroutine
port: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 143 | 0 | confess 'function port not overloaded'; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | =head2 serve | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | =cut | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub serve { | ||||||||||||||||||||||||||
|
Subroutine
serve: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 151 | 0 | confess 'function serve not overloaded'; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =head2 close | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =cut | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||
|
Subroutine
close: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 159 | 0 | my ($self, $cb) = @_; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | unless (ref($cb) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | confess '$cb is not CODE'; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | $cb->(); | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | $self; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >> | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =head1 BUGS | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>. | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | perldoc Lim | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | You can also look for information at: | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | =over 4 | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | =item * Lim issue tracker (report bugs here) | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | L<https://github.com/jelu/lim/issues> | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =back | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | Copyright 2012-2013 Jerry Lundström. | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 201 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||
| 202 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | =cut | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 5 | 1; # End of Lim::RPC::Transport | |||||||||||||||||||||||||||