| 1 | package Lim::Component::Server; | ||||||||||||||||||||||||||||||||
| 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 Log::Log4perl (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Lim (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Lim::RPC (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Lim::Error (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | =encoding utf8 | ||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | ... | ||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | =head1 VERSION | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | See L<Lim> for version. | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 5 | our $VERSION = $Lim::VERSION; | |||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | ... | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | =head2 new | ||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | =cut | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | sub new { | ||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | my $this = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=18.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 39 | 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
| |||||||||||||||||||||||||||||||||
| 40 | 4 | my $self = { | |||||||||||||||||||||||||||||||
| 41 | logger => Log::Log4perl->get_logger | ||||||||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||||||
| 43 | 4 | bless $self, $class; | |||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 4 | eval { | |||||||||||||||||||||||||||||||
| 46 | 4 | $self->Init(@_); | |||||||||||||||||||||||||||||||
| 47 | }; | ||||||||||||||||||||||||||||||||
| 48 | 4 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('Unable to initialize module '.$class.': '.$@); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 50 | 0 | return; | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 4 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 54 | 4 | $self; | |||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | sub DESTROY { | ||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | 4 | $self->Destroy; | |||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | =head2 Init | ||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | =cut | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | ▶ | sub Init { | |||||||||||||||||||||||||||||||
|
Subroutine
Init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | =head2 Destroy | ||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | ▶ | sub Destroy { | |||||||||||||||||||||||||||||||
|
Subroutine
Destroy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | =head2 Successful | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | sub Successful { | ||||||||||||||||||||||||||||||||
| 83 | 4 | ▶ | my ($self, $cb, $data) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
Successful: called CC=4 SCAR=19.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | 4 | eval { | |||||||||||||||||||||||||||||||
| 86 | 4 | Lim::RPC::R($cb, $data); | |||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | Lim::WARN and $self->{logger}->warn('data validation failed: ', $@); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | Lim::DEBUG and eval { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 91 | 5 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 92 | 0 | $self->{logger}->debug(Dumper($data)); | |||||||||||||||||||||||||||||||
| 93 | 0 | $self->{logger}->debug(Dumper($cb->call_def->{out})); | |||||||||||||||||||||||||||||||
| 94 | }; | ||||||||||||||||||||||||||||||||
| 95 | 0 | Lim::RPC::R($cb, Lim::Error->new()); | |||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | =head2 Error | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | =cut | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | sub Error { | ||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | my ($self, $cb, $error, @rest) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
Error: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if (blessed($error) and $error->isa('Lim::Error')) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
builtin::blessed($error) and $error->isa("Lim::Error")
MC/DC0%0/2
builtin::blessed($error) and $error->isa("Lim::Error")
builtin::blessed($error)
$error->isa("Lim::Error")
Truth table0%0/3
A and B
A= builtin::blessed($error)B= $error->isa("Lim::Error")
| |||||||||||||||||||||||||||||||||
| 107 | 0 | Lim::RPC::R($cb, $error); | |||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | elsif (defined $error) { | ||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (scalar @rest) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 111 | 0 | $error .= join('', @rest); | |||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||
| 113 | 0 | Lim::RPC::R($cb, Lim::Error->new(module => $self, message => $error)); | |||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | else { | ||||||||||||||||||||||||||||||||
| 116 | 0 | Lim::RPC::R($cb, Lim::Error->new(module => $self)); | |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >> | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | =head1 BUGS | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>. | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | perldoc Lim | ||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | You can also look for information at: | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | =over 4 | ||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | =item * Lim issue tracker (report bugs here) | ||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | L<https://github.com/jelu/lim/issues> | ||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | =back | ||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | Copyright 2012-2013 Jerry Lundström. | ||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||
| 150 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||
| 151 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||||||
| 152 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | =cut | ||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 5 | 1; # End of Lim::RPC::Base | |||||||||||||||||||||||||||||||