blib/lib/WebDyne/Cloudflare/Hyperdrive.pm

filter: Statementstmt 96.4% 192 / 199 Branchbran 76.1% 67 / 88 Conditioncond 51.3% 37 / 72 MC/DCmcdc 31.7% 13 / 41 Subroutinesub 96.9% 32 / 33 Podpod 0.0% 0 / 20 totaltotal 75.2% 341 / 453 CC 69 SCAR 22.0
CC
69
Cov
82%
blob
42.0
run_transaction
16.2
send_request
10.5
CRAP 9.1
« blib/lib/WebDyne/Cloudflare/KV.pm ↑ Summary blib/lib/WebDyne/Cloudflare.pm »
1 package WebDyne::Cloudflare::Hyperdrive;
2  
3 1 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use WebDyne::Cloudflare::Hyperdrive::Transport;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use WebDyne::Cloudflare::Hyperdrive::Statement;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use WebDyne::Cloudflare::Hyperdrive::Blob;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use WebDyne::Cloudflare::Hyperdrive::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 our $VERSION='0.001';
15  
16 7 ▶sub new {
Subroutine new: called CC=3 SCAR=12.0
Pod undocumented
17 7 my ($class, %opt)=@_;
18 7 ▶ die "Unknown Hyperdrive constructor option\n" if grep { ($_ ne 'scope')&&($_ ne 'binding') } keys(%opt);
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ ne "scope" and $_ ne "binding";} keys %opt 0 7 7
Condition33%1/3
$_ ne 'scope' && $_ ne 'binding'
!ll&&!rl&&r
700
MC/DC0%0/2
$_ ne 'scope' && $_ ne 'binding'
$_ ne 'scope' $_ ne 'binding'
Truth table33%1/3
A && B
A= $_ ne 'scope'B= $_ ne 'binding'
ABresult
0X0
100
111
19 7 return bless({ transport => WebDyne::Cloudflare::Hyperdrive::Transport->new(%opt), pending => 0 }, $class);
20 }
21  
22  
23 156 ▶sub root { return $_[0]->{'root'}||$_[0]; }
Subroutine root: called CC=2 SCAR=7.2
Pod undocumented
Condition66%2/3
$_[0]{'root'} || $_[0]
l!l&&r!l&&!r
101460
MC/DC0%0/2
$_[0]{'root'} || $_[0]
$_[0]{'root'} $_[0]
Truth table66%2/3
A || B
A= $_[0]{'root'}B= $_[0]
ABresult
1X1
011
000
24  
25  
26 107 ▶sub available {
Subroutine available: called CC=8 SCAR=20.8
Pod undocumented
27 107 my ($self)=@_;
28 107 my $root_or=$self->root();
29 107 ▶ die "Hyperdrive connection is disconnected\n" if $root_or->{'closed'}||$root_or->{'closing'};
Branch: 1 branch
BranchTrueFalseTotal
if $root_or->{"closed"} or $root_or->{"closing"} 2 105 107
Condition66%2/3
$root_or->{"closed"} or $root_or->{"closing"}
l!l&&r!l&&!r
20105
MC/DC50%1/2
$root_or->{"closed"} or $root_or->{"closing"}
$root_or->{"closed"} $root_or->{"closing"}
Truth table66%2/3
A or B
A= $root_or->{"closed"}B= $root_or->{"closing"}
ABresult
1X1
011
000
30 105 ▶ die "Hyperdrive connection was cancelled or cleanup failed; disconnect it\n" if $root_or->{'cancelled'};
Branch: 1 branch
BranchTrueFalseTotal
if $root_or->{"cancelled"} 2 103 105
31 103 ▶ die "Hyperdrive transaction handle has expired\n" if $self->{'root'}&&!$self->{'active'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"root"} and not $self->{"active"} 3 100 103
Condition100%3/3
$self->{"root"} and not $self->{"active"}
!ll&&!rl&&r
9643
MC/DC100%2/2
$self->{"root"} and not $self->{"active"}
$self->{"root"} not $self->{"active"}
Truth table100%3/3
A and not(B)
A= $self->{"root"}B= not $self->{"active"}
ABresult
0X0
100
111
32 100 ▶ die "Hyperdrive connection belongs to a transaction callback\n" if !$self->{'root'}&&$root_or->{'managed'};
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"root"} and $root_or->{"managed"} 1 99 100
Condition100%3/3
not $self->{"root"} and $root_or->{"managed"}
!ll&&!rl&&r
4951
MC/DC100%2/2
not $self->{"root"} and $root_or->{"managed"}
not $self->{"root"} $root_or->{"managed"}
Truth table100%3/3
not(A) and B
A= not $self->{"root"}B= $root_or->{"managed"}
ABresult
0X0
100
111
33 99 return 1;
34 }
35  
36  
37 21 ▶sub attributes {
Subroutine attributes: called CC=8 SCAR=20.8
Pod undocumented
38 21 my ($attr_hr, $slice_fg)=@_;
39 21 ▶ return 0 unless defined($attr_hr);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $attr_hr 16 5 21
40 5 ▶ die "Hyperdrive attributes must be a hash or undef\n" unless ref($attr_hr) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $attr_hr eq "HASH" 0 5 5
41 5 ▶ die "Unsupported Hyperdrive attribute\n" if grep { !$slice_fg||($_ ne 'Slice') } keys(%{$attr_hr});
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $slice_fg or $_ ne "Slice";} keys %{$attr_hr;} 2 3 5
Condition100%3/3
!$slice_fg || $_ ne 'Slice'
l!l&&r!l&&!r
113
MC/DC100%2/2
!$slice_fg || $_ ne 'Slice'
!$slice_fg $_ ne 'Slice'
Truth table100%3/3
not(A) || B
A= !$slice_fgB= $_ ne 'Slice'
ABresult
1X1
011
000
42 3 ▶ return 0 unless exists($attr_hr->{'Slice'});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $attr_hr->{"Slice"} 0 3 3
43 3 ▶ die "Hyperdrive Slice must be an empty hash\n" unless (ref($attr_hr->{'Slice'}) eq 'HASH')&&!keys(%{$attr_hr->{'Slice'}});
Branch: 1 branch
BranchTrueFalseTotal
unless ref $attr_hr->{"Slice"} eq "HASH" and not keys %{$$attr_hr{"Slice"};} 2 1 3
Condition100%3/3
ref $attr_hr->{"Slice"} eq "HASH" and not keys %{$$attr_hr{"Slice"};}
!ll&&!rl&&r
111
MC/DC100%2/2
ref $attr_hr->{"Slice"} eq "HASH" and not keys %{$$attr_hr{"Slice"};}
ref $attr_hr->{"Slice"} eq "HASH" not keys %{$$attr_hr{"Slice"};}
Truth table100%3/3
A and not(B)
A= ref $attr_hr->{"Slice"} eq "HASH"B= not keys %{$$attr_hr{"Slice"};}
ABresult
0X0
100
111
44 1 return 1;
45 }
46  
47  
48 0 ▶sub blob {
Subroutine blob: not called CC=6 SCAR=37.4
Pod undocumented
49 0 ▶ shift() if (@_>1)&&defined($_[0])&&(blessed($_[0])||($_[0] eq __PACKAGE__));
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 and defined $_[0] and builtin::blessed($_[0]) || $_[0] eq __PACKAGE__ 0 0 0
Condition0%0/9
@_ > 1 and defined $_[0] and builtin::blessed($_[0]) || $_[0] eq __PACKAGE__
!ll&&!rl&&r
000
@_ > 1 and defined $_[0]
!ll&&!rl&&r
000
builtin::blessed($_[0]) or $_[0] eq __PACKAGE__
l!l&&r!l&&!r
000
MC/DC0%0/4
@_ > 1 and defined $_[0] and builtin::blessed($_[0]) || $_[0] eq __PACKAGE__
@_ > 1 defined $_[0] builtin::blessed($_[0]) $_[0] eq __PACKAGE__
Truth table0%0/5
A and B and C or D
A= @_ > 1B= defined $_[0]C= builtin::blessed($_[0])D= $_[0] eq __PACKAGE__
ABCDresult
0XXX0
10XX0
11000
111X1
11011
50 0 ▶ die "Hyperdrive blob requires exactly one byte string\n" unless @_==1;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
51 0 return WebDyne::Cloudflare::Hyperdrive::Blob->new($_[0]);
52 }
53  
54  
55 21 ▶sub prepare {
Subroutine prepare: called CC=6 SCAR=21.6
Pod undocumented
56 21 my ($self, $sql, $attr_hr)=@_;
57 21 $self->available();
58 16 ▶ die "Hyperdrive prepare takes SQL and optional attributes\n" if @_>3;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 3 0 16 16
59 16 attributes($attr_hr, 0);
60 15 ▶ die "Hyperdrive SQL must be a non-empty string\n" unless defined($sql)&&!ref($sql)&&($sql=~/\S/)&&index($sql, "\0")<0;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sql and not ref $sql and $sql =~ /\S/u and index($sql, "\0") == -1 0 15 15
Condition33%3/9
defined $sql and not ref $sql and $sql =~ /\S/u and index($sql, "\0") == -1
!ll&&!rl&&r
0015
defined $sql and not ref $sql and $sql =~ /\S/u
!ll&&!rl&&r
0015
defined $sql and not ref $sql
!ll&&!rl&&r
0015
MC/DC0%0/4
defined $sql and not ref $sql and $sql =~ /\S/u and index($sql, "\0") == -1
defined $sql not ref $sql $sql =~ /\S/u index($sql, "\0") == -1
Truth table20%1/5
A and not(B) and C and D
A= defined $sqlB= not ref $sqlC= $sql =~ /\S/uD= index($sql, "\0") == -1
ABCDresult
0XXX0
10XX0
110X0
11100
11111
61 15 return WebDyne::Cloudflare::Hyperdrive::Statement->new(database => $self, sql => $sql);
62 }
63  
64  
65 5 ▶async sub selectrow_arrayref {
Subroutine selectrow_arrayref: called CC=1 SCAR=0.0
Pod undocumented
66 5 my ($self, $sql, $attr_hr, @bind)=@_;
67 5 my $statement_or=$self->prepare($sql, $attr_hr);
68 4 await $statement_or->execute(@bind);
69 3 return $statement_or->fetchrow_arrayref();
70 1 }
71  
72  
73 2 ▶async sub selectrow_hashref {
Subroutine selectrow_hashref: called CC=1 SCAR=0.0
Pod undocumented
74 2 my ($self, $sql, $attr_hr, @bind)=@_;
75 2 my $statement_or=$self->prepare($sql, $attr_hr);
76 2 await $statement_or->execute(@bind);
77 2 return $statement_or->fetchrow_hashref();
78 1 }
79  
80  
81 5 ▶async sub selectall_arrayref {
Subroutine selectall_arrayref: called CC=2 SCAR=6.9
Pod undocumented
82 5 my ($self, $sql, $attr_hr, @bind)=@_;
83 5 my $slice_fg=attributes($attr_hr, 1);
84 2 my $statement_or=$self->prepare($sql);
85 2 await $statement_or->execute(@bind);
86 2 ▶ return $statement_or->fetchall_arrayref($slice_fg ? {} : undef);
Branch: 1 branch
BranchTrueFalseTotal
$slice_fg ? : 1 1 2
87 1 }
88  
89  
90 3 ▶async sub do {
Subroutine do: called CC=1 SCAR=0.0
Pod undocumented
91 3 my ($self, $sql, $attr_hr, @bind)=@_;
92 3 return await $self->prepare($sql, $attr_hr)->execute(@bind);
93 1 }
94  
95  
96 48 ▶sub request {
Subroutine request: called CC=1 SCAR=0.0
Pod undocumented
97 48 my ($self, $operation, %opt)=@_;
98 48 $self->{'pending'}++;
99 48 my $future_or=$self->send_request($operation, %opt);
100 # Retain the operation until bookkeeping runs, including cancellation.
101 #
102 48 ▶ $future_or->on_ready(sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
103 48 $self->{'pending'}--;
104 48 ▶ $self->root()->{'cancelled'}=1 if $future_or->is_cancelled();
Branch: 1 branch
BranchTrueFalseTotal
if $future_or->is_cancelled 1 47 48
105 48 });
106 48 return $future_or;
107 }
108  
109  
110 48 ▶async sub send_request {
Subroutine send_request: called CC=9 SCAR=23.5
Pod undocumented
111 48 my ($self, $operation, %opt)=@_;
112 48 my $root_or=$self->root();
113 48 ▶ if (!$root_or->{'connection'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($root_or->{"connection"}) 6 42 48
114 6 ▶ $root_or->{'opening'}=$root_or->{'transport'}->call('open') unless $root_or->{'opening'};
Branch: 1 branch
BranchTrueFalseTotal
unless $root_or->{"opening"} 6 0 6
115 6 my $opened_hr=await $root_or->{'opening'}->without_cancel();
116 6 ▶ die "Hyperdrive host omitted connection identity\n" unless defined($opened_hr->{'connection'})&&!ref($opened_hr->{'connection'})&&length($opened_hr->{'connection'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opened_hr->{"connection"} and not ref $opened_hr->{"connection"} and length $opened_hr->{"connection"} 0 6 6
Condition33%2/6
defined $opened_hr->{"connection"} and not ref $opened_hr->{"connection"} and length $opened_hr->{"connection"}
!ll&&!rl&&r
006
defined $opened_hr->{"connection"} and not ref $opened_hr->{"connection"}
!ll&&!rl&&r
006
MC/DC0%0/3
defined $opened_hr->{"connection"} and not ref $opened_hr->{"connection"} and length $opened_hr->{"connection"}
defined $opened_hr->{"connection"} not ref $opened_hr->{"connection"} length $opened_hr->{"connection"}
Truth table25%1/4
A and not(B) and C
A= defined $opened_hr->{"connection"}B= not ref $opened_hr->{"connection"}C= length $opened_hr->{"connection"}
ABCresult
0XX0
10X0
1100
1111
117 6 $root_or->{'connection'}=$opened_hr->{'connection'};
118 }
119 48 ▶ die "Hyperdrive transaction handle has expired\n" if $self->{'root'}&&!$self->{'active'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"root"} and not $self->{"active"} 0 48 48
Condition66%2/3
$self->{"root"} and not $self->{"active"}
!ll&&!rl&&r
4620
MC/DC0%0/2
$self->{"root"} and not $self->{"active"}
$self->{"root"} not $self->{"active"}
Truth table66%2/3
A and not(B)
A= $self->{"root"}B= not $self->{"active"}
ABresult
0X0
100
111
120 48 ▶ $opt{'owner'}=$self->{'owner'} if $self->{'root'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"root"} 2 46 48
121 48 return await $root_or->{'transport'}->call($operation, connection => $root_or->{'connection'}, %opt);
122 1 }
123  
124  
125 15 ▶sub control_allowed {
Subroutine control_allowed: called CC=2 SCAR=6.9
Pod undocumented
126 15 my ($self)=@_;
127 15 ▶ die "Explicit transaction control is unavailable inside a callback\n" if $self->{'root'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"root"} 2 13 15
128 13 $self->available();
129 }
130  
131  
132 1 ▶async sub begin_work {
Subroutine begin_work: called CC=2 SCAR=7.0
Pod undocumented
133 1 my ($self)=@_;
134 1 $self->control_allowed();
135 1 ▶ die "Hyperdrive begin_work takes no arguments\n" unless @_==1;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 1 1
136 1 await $self->request('begin', managed => JSON::PP::false());
137 1 $self->{'transaction'}=1;
138 1 return 1;
139 1 }
140  
141  
142 1 ▶async sub commit {
Subroutine commit: called CC=2 SCAR=11.6
Pod undocumented
143 1 my ($self)=@_;
144 1 $self->control_allowed();
145 0 ▶ die "Hyperdrive commit takes no arguments\n" unless @_==1;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
146 0 await $self->request('commit');
147 0 $self->{'transaction'}=0;
148 0 return 1;
149 1 }
150  
151  
152 1 ▶async sub rollback {
Subroutine rollback: called CC=2 SCAR=7.0
Pod undocumented
153 1 my ($self)=@_;
154 1 $self->control_allowed();
155 1 ▶ die "Hyperdrive rollback takes no arguments\n" unless @_==1;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 1 1
156 1 await $self->request('rollback');
157 1 $self->{'transaction'}=0;
158 1 return 1;
159 1 }
160  
161  
162 12 ▶sub transaction {
Subroutine transaction: called CC=5 SCAR=16.3
Pod undocumented
163 12 my ($self, $callback_cr)=@_;
164 12 $self->control_allowed();
165 11 ▶ die "Hyperdrive transaction requires one callback\n" unless (@_==2)&&(ref($callback_cr) eq 'CODE');
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 and ref $callback_cr eq "CODE" 0 11 11
Condition33%1/3
@_ == 2 and ref $callback_cr eq "CODE"
!ll&&!rl&&r
0011
MC/DC0%0/2
@_ == 2 and ref $callback_cr eq "CODE"
@_ == 2 ref $callback_cr eq "CODE"
Truth table33%1/3
A and B
A= @_ == 2B= ref $callback_cr eq "CODE"
ABresult
0X0
100
111
166 11 ▶ die "Nested Hyperdrive transactions are unsupported\n" if $self->{'transaction'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transaction"} 1 10 11
167 10 ▶ die "Await earlier Hyperdrive operations before starting a transaction callback\n" if $self->{'pending'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"pending"} 0 10 10
168 10 $self->{'managed'}=1;
169 10 my $facade_or=bless({ root => $self, active => 1, pending => 0 }, ref($self));
170 10 my $future_or=$self->run_transaction($callback_cr, $facade_or);
171 10 ▶ $future_or->on_ready(sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
172 10 $facade_or->{'active'}=0;
173 10 $self->{'managed'}=0;
174 10 ▶ $self->{'cancelled'}=1 if $future_or->is_cancelled();
Branch: 1 branch
BranchTrueFalseTotal
if $future_or->is_cancelled 1 9 10
175 10 });
176 10 return $future_or;
177 }
178  
179  
180 10 ▶async sub run_transaction {
Subroutine run_transaction: called CC=16 SCAR=27.9
Pod undocumented
181 10 my ($self, $callback_cr, $facade_or)=@_;
182 10 my $begun_hr=await $self->request('begin', managed => JSON::PP::true());
183 10 ▶ die "Hyperdrive host omitted transaction ownership\n" unless defined($begun_hr->{'owner'})&&!ref($begun_hr->{'owner'})&&length($begun_hr->{'owner'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $begun_hr->{"owner"} and not ref $begun_hr->{"owner"} and length $begun_hr->{"owner"} 0 10 10
Condition33%2/6
defined $begun_hr->{"owner"} and not ref $begun_hr->{"owner"} and length $begun_hr->{"owner"}
!ll&&!rl&&r
0010
defined $begun_hr->{"owner"} and not ref $begun_hr->{"owner"}
!ll&&!rl&&r
0010
MC/DC0%0/3
defined $begun_hr->{"owner"} and not ref $begun_hr->{"owner"} and length $begun_hr->{"owner"}
defined $begun_hr->{"owner"} not ref $begun_hr->{"owner"} length $begun_hr->{"owner"}
Truth table25%1/4
A and not(B) and C
A= defined $begun_hr->{"owner"}B= not ref $begun_hr->{"owner"}C= length $begun_hr->{"owner"}
ABCresult
0XX0
10X0
1100
1111
184 10 $facade_or->{'owner'}=$begun_hr->{'owner'};
185 10 $self->{'owner'}=$begun_hr->{'owner'};
186 10 $self->{'transaction'}=1;
187 10 my $value_ref;
188 10 my $ok_fg=eval {
189 10 my $callback_or=$callback_cr->($facade_or);
190 10 ▶ die "Hyperdrive transaction callback must return a Future\n" unless blessed($callback_or)&&$callback_or->isa('Future');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($callback_or) and $callback_or->isa("Future") 1 9 10
Condition66%2/3
builtin::blessed($callback_or) and $callback_or->isa("Future")
!ll&&!rl&&r
109
MC/DC50%1/2
builtin::blessed($callback_or) and $callback_or->isa("Future")
builtin::blessed($callback_or) $callback_or->isa("Future")
Truth table66%2/3
A and B
A= builtin::blessed($callback_or)B= $callback_or->isa("Future")
ABresult
0X0
100
111
191 9 $value_ref=await $callback_or;
192 5 ▶ die "Hyperdrive transaction callback left unfinished operations\n" if $facade_or->{'pending'};
Branch: 1 branch
BranchTrueFalseTotal
if $facade_or->{"pending"} 1 4 5
193 4 1;
194 };
195 9 my $error_ref=$@;
196 9 $facade_or->{'active'}=0;
197 9 ▶ if ($ok_fg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ok_fg) 4 5 9
198 4 $ok_fg=eval { await $self->request('commit', owner => $facade_or->{'owner'}); 1 };
199 4 $error_ref=$@;
200 4 ▶ $self->{'transaction'}=0 if $ok_fg;
Branch: 1 branch
BranchTrueFalseTotal
if $ok_fg 3 1 4
201 4 ▶ delete($self->{'owner'}) if $ok_fg;
Branch: 1 branch
BranchTrueFalseTotal
if $ok_fg 3 1 4
202 }
203 9 ▶ if (!$ok_fg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok_fg) 6 3 9
204 6 ▶ unless (blessed($error_ref)&&$error_ref->isa('WebDyne::Cloudflare::Hyperdrive::Error')&&$error_ref->outcome_unknown()) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($error_ref) and $error_ref->isa("WebDyne::Cloudflare::Hyperdrive::Error") and $error_ref->outcome_unknown) 5 1 6
Condition83%5/6
builtin::blessed($error_ref) and $error_ref->isa("WebDyne::Cloudflare::Hyperdrive::Error") and $error_ref->outcome_unknown
!ll&&!rl&&r
321
builtin::blessed($error_ref) and $error_ref->isa("WebDyne::Cloudflare::Hyperdrive::Error")
!ll&&!rl&&r
303
MC/DC66%2/3
builtin::blessed($error_ref) and $error_ref->isa("WebDyne::Cloudflare::Hyperdrive::Error") and $error_ref->outcome_unknown
builtin::blessed($error_ref) $error_ref->isa("WebDyne::Cloudflare::Hyperdrive::Error") $error_ref->outcome_unknown
Truth table75%3/4
A and B and C
A= builtin::blessed($error_ref)B= $error_ref->isa("WebDyne::Cloudflare::Hyperdrive::Error")C= $error_ref->outcome_unknown
ABCresult
0XX0
10X0
1100
1111
205 5 my $rolled_fg=eval { await $self->request('rollback', owner => $facade_or->{'owner'}); 1 };
206 5 my $cleanup_ref=$@;
207 5 ▶ if ($rolled_fg) { $self->{'transaction'}=0; delete($self->{'owner'}) }
Branch: 1 branch
BranchTrueFalseTotal
if ($rolled_fg) { } 3 2 5
208 else {
209 2 $self->{'cancelled'}=1;
210 2 $error_ref=WebDyne::Cloudflare::Hyperdrive::Error->with_cleanup($error_ref, $cleanup_ref);
211 }
212 }
213 6 ▶ $self->{'cancelled'}=1 if $self->{'transaction'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transaction"} 3 3 6
214 6 die $error_ref;
215 }
216 3 return $value_ref;
217 1 }
218  
219  
220 8 ▶sub disconnect {
Subroutine disconnect: called CC=5 SCAR=16.5
Pod undocumented
221 8 my ($self)=@_;
222 8 ▶ die "Disconnect is unavailable inside a transaction callback\n" if $self->{'root'}||$self->{'managed'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"root"} or $self->{"managed"} 0 8 8
Condition33%1/3
$self->{"root"} or $self->{"managed"}
l!l&&r!l&&!r
008
MC/DC0%0/2
$self->{"root"} or $self->{"managed"}
$self->{"root"} $self->{"managed"}
Truth table33%1/3
A or B
A= $self->{"root"}B= $self->{"managed"}
ABresult
1X1
011
000
223 8 ▶ die "Hyperdrive disconnect takes no arguments\n" unless @_==1;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 8 8
224 8 ▶ return $self->{'disconnecting'} if $self->{'disconnecting'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"disconnecting"} 1 7 8
225 7 $self->{'closing'}=1;
226 7 my $future_or=$self->close_connection();
227 7 $self->{'disconnecting'}=$future_or;
228 7 ▶ $future_or->on_ready(sub { $self->{'closed'}=1; $self->{'transaction'}=0; });
Subroutine __ANON__: called CC=1 SCAR=0.0
229 7 return $future_or;
230 }
231  
232  
233 7 ▶async sub close_connection {
Subroutine close_connection: called CC=4 SCAR=13.9
Pod undocumented
234 7 my ($self)=@_;
235 7 ▶ if ($self->{'connection'}||$self->{'opening'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"connection"} or $self->{"opening"}) 6 1 7
Condition66%2/3
$self->{"connection"} or $self->{"opening"}
l!l&&r!l&&!r
601
MC/DC50%1/2
$self->{"connection"} or $self->{"opening"}
$self->{"connection"} $self->{"opening"}
Truth table66%2/3
A or B
A= $self->{"connection"}B= $self->{"opening"}
ABresult
1X1
011
000
236 6 ▶ await $self->request('disconnect', (defined($self->{'owner'}) ? (owner => $self->{'owner'}) : ()));
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'owner'} ? : 4 2 6
237 }
238 7 return 1;
239 1 }
240  
241 1 1;
« blib/lib/WebDyne/Cloudflare/KV.pm ↑ Summary blib/lib/WebDyne/Cloudflare.pm »