Clio/Server/TCP.pm

filter: Statementstmt 52.9% 18 / 34 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 54.5% 24 / 44 CC 2 SCAR 8.6
CC
2
Cov
50%
__ANON__
6.0
start
2.0
BEGIN
1.0
CRAP 2.4
« Clio/Log/Log4perl.pm ↑ Summary Clio/Server/ClientsManager.pm »
1  
2 package Clio::Server::TCP;
3 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 $Clio::Server::TCP::AUTHORITY = 'cpan:AJGB';
5 }
6 {
7 1 $Clio::Server::TCP::VERSION = '0.02';
8 }
9 # ABSTRACT: Clio TCP Server
10  
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use AnyEvent;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use AnyEvent::Socket qw( tcp_server );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 extends qw( Clio::Server );
18  
19 1 with 'Clio::Role::UUIDMaker';
20  
21  
22 0 ▶sub start {
Subroutine start: not called CC=1 SCAR=6.9
Pod documented
23 0 my $self = shift;
24  
25 0 my $config = $self->c->config;
26  
27 0 my $log = $self->c->log;
28  
29 0 my $listen = $config->server_host_port;
30  
31 0 my $clients_manager = $self->clients_manager;
32  
33 0 ▶ my $guard = tcp_server $listen->{host}, $listen->{port}, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
34 0 my ($fh, $host, $port) = @_;
35  
36 0 my $uuid = $self->create_uuid;
37  
38 0 my $client = $clients_manager->new_client(
39 id => $uuid,
40 fh => $fh,
41 );
42  
43 0 ▶ if ( my $process = $self->c->process_manager->get_first_available ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $process = $self->c->process_manager->get_first_available) { } 0 0 0
44  
45 0 $client->attach_to_process( $process );
46 0 $process->add_client( $client );
47 } else {
48 0 $client->write("Too many connections\r\n");
49 0 $clients_manager->disconnect_client( $client->id );
50 }
51 0 };
52  
53 0 $log->info("Started ", __PACKAGE__, " on $listen->{host}:$listen->{port}");
54 0 AnyEvent->condvar->recv;
55 }
56  
57 1 1;
58  
59  
60 __END__
« Clio/Log/Log4perl.pm ↑ Summary Clio/Server/ClientsManager.pm »