| 1 | package Lim::RPC::Server; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use common::sense; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Log::Log4perl (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Scalar::Util qw(blessed weaken); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use URI (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use URI::Split (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use Lim (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use Lim::RPC (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 10 | ▶ | use Lim::RPC::Value (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 10 | ▶ | use Lim::RPC::Value::Collection (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 10 | ▶ | use Lim::RPC::Protocols (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 10 | ▶ | use Lim::RPC::Transports (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 10 | ▶ | use Lim::RPC::URIMaps (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | See L<Lim> for version. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | our $VERSION = $Lim::VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | ▶ | my $this = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=26.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | my %args = ( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 49 | logger => Log::Log4perl->get_logger, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | protocol => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | transports => [], | ||||||||||||||||||||||||||||||||||||||||||
| 52 | module => {} | ||||||||||||||||||||||||||||||||||||||||||
| 53 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | ▶ | unless (defined $args{uri}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | confess __PACKAGE__, ': No uri specified'; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | foreach my $uri (ref($args{uri}) eq 'ARRAY' ? @{$args{uri}} : $args{uri}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | my ($scheme, $auth, $path, $query, $frag) = URI::Split::uri_split($uri); | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | ▶ | if ($scheme =~ /^([a-z0-9_\-\.]+)(?:\+([a-z0-9_\-\.\+]+))*/o) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | my ($transport_name, $protocols) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | my (@protocols, $transport); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | $uri = URI->new('', 'http'); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | $uri->query($query); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | $uri->host_port($auth); | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | foreach my $protocol_name (split(/\+/o, $protocols)) { | |||||||||||||||||||||||||||||||||||||||||
| 71 | 4 | ▶ | unless (exists $self->{protocol}->{$protocol_name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | my $protocol; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | unless (defined ($protocol = Lim::RPC::Protocols->instance->protocol($protocol_name, server => $self))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | confess __PACKAGE__, ': Protocol ', $protocol_name, ' does not exists'; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | $self->{protocol}->{$protocol_name} = $protocol; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | push(@protocols, $protocol); | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | push(@protocols, $self->{protocol}->{$protocol_name}); | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | ▶ | unless (defined ($transport = Lim::RPC::Transports->instance->transport($transport_name, server => $self, uri => $uri))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | confess __PACKAGE__, ': Transport ', $transport_name, ' does not exists'; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | $transport->add_protocol(@protocols); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | push(@{$self->{transports}}, $transport); | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | confess __PACKAGE__, ': Unable to parse URI schema: ', $uri; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 4 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 4 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | delete $self->{transports}; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | delete $self->{module}; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | delete $self->{protocol}; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | =head2 serve | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | sub serve { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | ▶ | my ($self) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serve: called CC=80 SCAR=71.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 4 | foreach my $module (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 119 | 4 | my $obj; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 4 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | $obj = $module->Server; | |||||||||||||||||||||||||||||||||||||||||
| 123 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | ▶ | if (!defined $obj or $@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $obj or $@
MC/DC0%0/2
not defined $obj or $@
not defined $obj
$@
Truth table33%1/3
not(A) or B
A= not defined $objB= $@
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $module, (defined $@ ? ': '.$@ : '')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | ▶ | if ($obj->isa('Lim::Component::Server')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | my $name = lc($module->Name); | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | ▶ | if (exists $self->{module}->{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': plugin already served'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 4 | ▶ | unless ($module->VERSION) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': no VERSION specified in plugin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 4 | my $calls = $module->Calls; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 4 | ▶ | unless ($calls) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | Lim::INFO and $self->{logger}->info('Not serving ', $name, ', nothing to serve'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 4 | ▶ | unless (ref($calls) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': Calls() return was invalid'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | ▶ | unless (%$calls) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | Lim::INFO and $self->{logger}->info('Not serving ', $name, ', nothing to serve'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | my $uri_maps = {}; | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | foreach my $call (keys %$calls) { | |||||||||||||||||||||||||||||||||||||||||
| 159 | 20 | ▶ | unless ($obj->can($call)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': Missing specified call ', $call, ' function'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 20 | my $create_call = 0; | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 20 | foreach my $protocol_name (keys %{$self->{protocol}}) { | |||||||||||||||||||||||||||||||||||||||||
| 168 | 20 | my $base = 'Lim::RPC::ProtocolCall::'.$protocol_name.'::'.ref($obj); | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 20 | ▶ | if ($base->isa('UNIVERSAL') and $base->can($call)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$base->isa("UNIVERSAL") and $base->can($call)
MC/DC0%0/2
$base->isa("UNIVERSAL") and $base->can($call)
$base->isa("UNIVERSAL")
$base->can($call)
Truth table33%1/3
A and B
A= $base->isa("UNIVERSAL")B= $base->can($call)
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 20 | $create_call = 1; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 20 | last; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 20 | ▶ | if ($create_call) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 20 | my $call_def = $calls->{$call}; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 20 | ▶ | unless (ref($call_def) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': call ', $call, ' has invalid definition'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 20 | ▶ | if (exists $call_def->{uri_map}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 12 | ▶ | unless (ref($call_def->{uri_map}) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': call ', $call, ' has invalid uri_map parameter definition'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 12 | my $uri_map = Lim::RPC::URIMaps->new; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 12 | foreach my $map (@{$call_def->{uri_map}}) { | |||||||||||||||||||||||||||||||||||||||||
| 196 | 20 | ▶ | if (defined (my $redirect_call = $uri_map->add($map))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 20 | ▶ | if ($redirect_call) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 8 | ▶ | unless (exists $calls->{$redirect_call}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': call ', $call, ' has invalid uri_map: redirected to non-existing call ', $redirect_call); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': call ', $call, ' has invalid uri_map: ', $@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 12 | ▶ | unless (defined $calls) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 12 | $uri_maps->{$call} = $uri_map; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 20 | ▶ | if (exists $call_def->{in}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 12 | ▶ | unless (ref($call_def->{in}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': call ', $call, ' has invalid in parameter definition'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 12 | my @keys = keys %{$call_def->{in}}; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 12 | ▶ | unless (scalar @keys) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': call ', $call, ' has invalid in parameter definition'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 12 | my @values = ($call_def->{in}); | |||||||||||||||||||||||||||||||||||||||||
| 233 | 12 | ▶ | while (defined $calls and (my $value = shift(@values))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $calls and my $value = shift @values
MC/DC50%1/2
defined $calls and my $value = shift @values
defined $calls
my $value = shift @values
Truth table66%2/3
A and B
A= defined $callsB= my $value = shift @values
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 24 | foreach my $key (keys %$value) { | |||||||||||||||||||||||||||||||||||||||||
| 235 | 24 | ▶ | if (ref($value->{$key}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 12 | ▶ | if (exists $value->{$key}->{''}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my $collection = Lim::RPC::Value::Collection->new($value->{$key}->{''}); | |||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | delete $value->{$key}->{''}; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $value->{$key} = $collection->set_children($value->{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 241 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | unless ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | push(@values, $value->{$key}->children); | |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Unable to create Lim::RPC::Value::Collection: ', $@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 12 | push(@values, $value->{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 250 | 12 | next; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | elsif (blessed $value->{$key}) { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if ($value->{$key}->isa('Lim::RPC::Value')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if ($value->{$key}->isa('Lim::RPC::Value::Collection')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | push(@values, $value->{$key}->children); | |||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 12 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 264 | 12 | $value->{$key} = Lim::RPC::Value->new($value->{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 265 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 12 | ▶ | unless ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 12 | next; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Unable to create Lim::RPC::Value: ', $@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not server ', $name, ': call ', $call, ' has invalid in parameter definition'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 12 | ▶ | unless (defined $calls) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 20 | ▶ | if (exists $call_def->{out}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 20 | ▶ | unless (ref($call_def->{out}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': call ', $call, ' has invalid out parameter definition'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 20 | my @keys = keys %{$call_def->{out}}; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 20 | ▶ | unless (scalar @keys) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not serve ', $name, ': call ', $call, ' has invalid out parameter definition'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 20 | my @values = ($call_def->{out}); | |||||||||||||||||||||||||||||||||||||||||
| 297 | 20 | ▶ | while (defined $calls and (my $value = shift(@values))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $calls and my $value = shift @values
MC/DC50%1/2
defined $calls and my $value = shift @values
defined $calls
my $value = shift @values
Truth table66%2/3
A and B
A= defined $callsB= my $value = shift @values
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 36 | foreach my $key (keys %$value) { | |||||||||||||||||||||||||||||||||||||||||
| 299 | 76 | ▶ | if (ref($value->{$key}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 16 | ▶ | if (exists $value->{$key}->{''}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my $collection = Lim::RPC::Value::Collection->new($value->{$key}->{''}); | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | delete $value->{$key}->{''}; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $value->{$key} = $collection->set_children($value->{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 305 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | unless ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | push(@values, $value->{$key}->children); | |||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Unable to create Lim::RPC::Value::Collection: ', $@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 16 | push(@values, $value->{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 314 | 16 | next; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | elsif (blessed $value->{$key}) { | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($value->{$key}->isa('Lim::RPC::Value')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ($value->{$key}->isa('Lim::RPC::Value::Collection')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | push(@values, $value->{$key}->children); | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 60 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 328 | 60 | $value->{$key} = Lim::RPC::Value->new($value->{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 329 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 60 | ▶ | unless ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 60 | next; | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Unable to create Lim::RPC::Value: ', $@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Can not server ', $name, ': call ', $call, ' has invalid out parameter definition'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | undef($calls); | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 20 | ▶ | unless (defined $calls) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 20 | my $logger = $self->{logger}; | |||||||||||||||||||||||||||||||||||||||||
| 347 | 20 | weaken($logger); | |||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 20 | foreach my $protocol_name (keys %{$self->{protocol}}) { | |||||||||||||||||||||||||||||||||||||||||
| 350 | 20 | my $base = 'Lim::RPC::ProtocolCall::'.$protocol_name.'::'.ref($obj); | |||||||||||||||||||||||||||||||||||||||||
| 351 | 20 | my $protocol_call = $base.'::'.$call; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 20 | my $protocol = $self->{protocol}->{$protocol_name}; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 20 | weaken($protocol); | |||||||||||||||||||||||||||||||||||||||||
| 354 | 20 | my $weak_obj = $obj; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 20 | weaken($weak_obj); | |||||||||||||||||||||||||||||||||||||||||
| 356 | 20 | weaken($call_def); | |||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 20 | ▶ | if ($base->isa('UNIVERSAL') and $base->can($call)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$base->isa("UNIVERSAL") and $base->can($call)
MC/DC0%0/2
$base->isa("UNIVERSAL") and $base->can($call)
$base->isa("UNIVERSAL")
$base->can($call)
Truth table33%1/3
A and B
A= $base->isa("UNIVERSAL")B= $base->can($call)
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 10 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | *$protocol_call = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 4 | ▶ | unless (defined $protocol and defined $weak_obj and defined $call_def) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=25 SCAR=54.7
Branch: 1 branch
Condition33%2/6
defined $protocol and defined $weak_obj and defined $call_def
defined $protocol and defined $weak_obj
MC/DC0%0/3
defined $protocol and defined $weak_obj and defined $call_def
defined $protocol
defined $weak_obj
defined $call_def
Truth table25%1/4
A and B and C
A= defined $protocolB= defined $weak_objC= defined $call_def
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 4 | my ($self, $cb, $q, @args); | |||||||||||||||||||||||||||||||||||||||||
| 368 | 4 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 369 | 4 | ($self, $cb, $q, @args) = $protocol->precall($call, @_); | |||||||||||||||||||||||||||||||||||||||||
| 370 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 4 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | Lim::WARN and defined $logger and $logger->warn($weak_obj, '->', $call, '() precall failed: ', $@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Lim::WARN() and defined $logger
MC/DC0%0/2
Lim::WARN() and defined $logger
Lim::WARN()
defined $logger
Truth table0%0/3
A and B
A= Lim::WARN()B= defined $logger
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $weak_obj->Error($cb); | |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 4 | ▶ | Lim::RPC_DEBUG and defined $logger and $logger->debug('Call to ', $weak_obj, ' ', $call); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
Lim::RPC_DEBUG() and defined $logger
MC/DC0%0/2
Lim::RPC_DEBUG() and defined $logger
Lim::RPC_DEBUG()
defined $logger
Truth table33%1/3
A and B
A= Lim::RPC_DEBUG()B= defined $logger
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 4 | ▶ | if (!defined $q) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 4 | $q = {}; | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 4 | ▶ | if (ref($q) ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | Lim::WARN and defined $logger and $logger->warn($weak_obj, '->', $call, '() called without data as hash'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Lim::WARN() and defined $logger
MC/DC0%0/2
Lim::WARN() and defined $logger
Lim::WARN()
defined $logger
Truth table0%0/3
A and B
A= Lim::WARN()B= defined $logger
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $weak_obj->Error($cb); | |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 4 | ▶ | if (exists $call_def->{in}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | Lim::RPC::V($q, $call_def->{in}); | |||||||||||||||||||||||||||||||||||||||||
| 391 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | Lim::WARN and defined $logger and $logger->warn($weak_obj, '->', $call, '() data validation failed: ', $@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Lim::WARN() and defined $logger
MC/DC0%0/2
Lim::WARN() and defined $logger
Lim::WARN()
defined $logger
Truth table0%0/3
A and B
A= Lim::WARN()B= defined $logger
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | Lim::DEBUG and defined $logger and eval { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Lim::DEBUG() and defined $logger
MC/DC0%0/2
Lim::DEBUG() and defined $logger
Lim::DEBUG()
defined $logger
Truth table0%0/3
A and B
A= Lim::DEBUG()B= defined $logger
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 10 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $logger->debug(Dumper($q)); | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $logger->debug(Dumper($call_def->{in})); | |||||||||||||||||||||||||||||||||||||||||
| 398 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $weak_obj->Error($cb); | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | elsif (%$q) { | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | Lim::WARN and defined $logger and $logger->warn($weak_obj, '->', $call, '() have data but no definition'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Lim::WARN() and defined $logger
MC/DC0%0/2
Lim::WARN() and defined $logger
Lim::WARN()
defined $logger
Truth table0%0/3
A and B
A= Lim::WARN()B= defined $logger
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $weak_obj->Error($cb); | |||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 4 | $cb->set_call_def($call_def); | |||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 4 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 411 | 4 | $weak_obj->$call($cb, $q, @args); | |||||||||||||||||||||||||||||||||||||||||
| 412 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 4 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | Lim::WARN and defined $logger and $logger->warn($weak_obj, '->', $call, '() failed: ', $@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Lim::WARN() and defined $logger
MC/DC0%0/2
Lim::WARN() and defined $logger
Lim::WARN()
defined $logger
Truth table0%0/3
A and B
A= Lim::WARN()B= defined $logger
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $weak_obj->Error($cb); | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 20 | }; | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 4 | ▶ | unless ($calls) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 4 | ▶ | Lim::DEBUG and $self->{logger}->debug('serving ', $name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 4 | $self->{module}->{$name} = { | |||||||||||||||||||||||||||||||||||||||||
| 429 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 430 | module => $module, | ||||||||||||||||||||||||||||||||||||||||||
| 431 | obj => $obj, | ||||||||||||||||||||||||||||||||||||||||||
| 432 | calls => $calls, | ||||||||||||||||||||||||||||||||||||||||||
| 433 | uri_maps => $uri_maps | ||||||||||||||||||||||||||||||||||||||||||
| 434 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 4 | foreach my $protocol (values %{$self->{protocol}}) { | |||||||||||||||||||||||||||||||||||||||||
| 437 | 4 | $protocol->serve($module, $name); | |||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 4 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | =head2 have_module | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | sub have_module { | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 4 | ▶ | my ($self, $module) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
have_module: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 4 | ▶ | unless (exists $self->{module}->{$module}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | =head2 have_module_call | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | sub have_module_call { | ||||||||||||||||||||||||||||||||||||||||||
| 464 | 2 | ▶ | my ($self, $module, $call) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
have_module_call: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 2 | ▶ | unless (exists $self->{module}->{$module}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 2 | ▶ | unless (exists $self->{module}->{$module}->{calls}->{$call}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | =head2 module_obj | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | sub module_obj { | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 2 | ▶ | my ($self, $module) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
module_obj: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 2 | ▶ | unless (exists $self->{module}->{$module}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 2 | return $self->{module}->{$module}->{obj}; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | =head2 module_class | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | sub module_class { | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 6 | ▶ | my ($self, $module) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
module_class: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 6 | ▶ | unless (exists $self->{module}->{$module}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | 6 | return $self->{module}->{$module}->{module}; | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | =head2 module_obj_by_protocol | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | sub module_obj_by_protocol { | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 6 | ▶ | my ($self, $module, $protocol) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
module_obj_by_protocol: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 6 | ▶ | unless (exists $self->{module}->{$module}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 6 | ▶ | unless (exists $self->{protocol}->{$protocol}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | 6 | bless {}, 'Lim::RPC::ProtocolCall::'.$protocol.'::'.$self->{module}->{$module}->{module}.'::Server'; | |||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | =head2 process_module_call_uri_map | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | sub process_module_call_uri_map { | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | my ($self, $module, $call, $uri, $data) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_module_call_uri_map: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | unless (exists $self->{module}->{$module}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | unless (ref($data) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | unless (exists $self->{module}->{$module}->{uri_maps}->{$call}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | return $self->{module}->{$module}->{uri_maps}->{$call}->process($uri, $data); | |||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | =head2 transports | ||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | sub transports { | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 4 | ▶ | @{$_[0]->{transports}}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transports: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >> | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>. | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | perldoc Lim | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | =item * Lim issue tracker (report bugs here) | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | L<https://github.com/jelu/lim/issues> | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | Copyright 2012-2013 Jerry Lundström. | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 584 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||||||||||||||||
| 585 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | 10 | 1; # End of Lim::RPC::Server | |||||||||||||||||||||||||||||||||||||||||