File Coverage

blib/lib/Sys/Async/Virt/Connection/Process.pm
Criterion Covered Total %
statement 32 62 51.6
branch 0 4 0.0
condition n/a
subroutine 11 16 68.7
pod 1 3 33.3
total 44 85 51.7


line stmt bran cond sub pod time code
1             ####################################################################
2             #
3             # This file was generated using XDR::Parse version v1.0.1
4             # and LibVirt version v12.1.0
5             #
6             # Don't edit this file, use the source template instead
7             #
8             # ANY CHANGES HERE WILL BE LOST !
9             #
10             ####################################################################
11              
12              
13 1     1   1207 use v5.26;
  1         3  
14 1     1   4 use warnings;
  1         2  
  1         53  
15 1     1   5 use experimental 'signatures';
  1         1  
  1         7  
16 1     1   125 use Future::AsyncAwait;
  1         1  
  1         6  
17 1     1   44 use Object::Pad ':experimental(inherit_field)';
  1         1  
  1         7  
18              
19             class Sys::Async::Virt::Connection::Process v0.6.1;
20              
21             inherit Sys::Async::Virt::Connection '$_in', '$_out';
22              
23 1     1   324 use Carp qw(croak);
  1         3  
  1         44  
24 1     1   4 use Future::IO;
  1         1  
  1         57  
25 1     1   5 use IO::Handle;
  1         2  
  1         29  
26 1     1   446 use IPC::Open2;
  1         4388  
  1         271  
27 1     1   7 use Log::Any qw($log);
  1         2  
  1         8  
28              
29 1     1   205 use Protocol::Sys::Virt::URI v12.1.0; # imports parse_url
  1         16  
  1         849  
30              
31 0     0 0   field $_url :param :reader;
  0            
32             field $_pid;
33             field $_exit_f;
34              
35 0     0 0   async method close() {
  0            
  0            
  0            
36 0 0         unless ($_exit_f->is_ready) {
37 0           kill 'TERM', $_pid;
38             }
39             ### TODO: log exit status
40 0           await $_exit_f;
41             }
42              
43 0     0     method _command( $url ) {
  0            
  0            
  0            
44 0           my %c = parse_url( $url );
45 0           return $c{query}->{command};
46             }
47              
48 0     0 1   async method connect() {
  0            
  0            
  0            
49 0           my @cmd = $self->_command( $_url );
50 0           $log->trace('Connection process command: ' . join(' ', @cmd));
51              
52 0 0         $_pid = open2( $_in, $_out, @cmd )
53             or die "Unable to open external command: $!";
54 0           $_out->autoflush( 1 );
55 0           $_out->blocking( 0 );
56 0           $_in->autoflush( 1 );
57 0           $_in->blocking( 0 );
58 0           $_exit_f = Future::IO->waitpid( $_pid );
59 0     0     $_exit_f->on_ready(sub { $self->_finalize_io });
  0            
60              
61 0           return;
62             }
63              
64             1;
65              
66              
67             __END__