| 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
Condition33%1/3
$_ ne 'scope' && $_ ne 'binding'
MC/DC0%0/2
$_ ne 'scope' && $_ ne 'binding'
$_ ne 'scope'
$_ ne 'binding'
Truth table33%1/3
A && B
A= $_ ne 'scope'B= $_ ne 'binding'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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]
MC/DC0%0/2
$_[0]{'root'} || $_[0]
$_[0]{'root'}
$_[0]
Truth table66%2/3
A || B
A= $_[0]{'root'}B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$root_or->{"closed"} or $root_or->{"closing"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 105 | ▶ | die "Hyperdrive connection was cancelled or cleanup failed; disconnect it\n" if $root_or->{'cancelled'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 103 | ▶ | die "Hyperdrive transaction handle has expired\n" if $self->{'root'}&&!$self->{'active'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"root"} and not $self->{"active"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 100 | ▶ | die "Hyperdrive connection belongs to a transaction callback\n" if !$self->{'root'}&&$root_or->{'managed'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->{"root"} and $root_or->{"managed"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | ▶ | die "Hyperdrive attributes must be a hash or undef\n" unless ref($attr_hr) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | ▶ | die "Unsupported Hyperdrive attribute\n" if grep { !$slice_fg||($_ ne 'Slice') } keys(%{$attr_hr}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
!$slice_fg || $_ ne 'Slice'
MC/DC100%2/2
!$slice_fg || $_ ne 'Slice'
!$slice_fg
$_ ne 'Slice'
Truth table100%3/3
not(A) || B
A= !$slice_fgB= $_ ne 'Slice'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | ▶ | return 0 unless exists($attr_hr->{'Slice'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
ref $attr_hr->{"Slice"} eq "HASH" and not keys %{$$attr_hr{"Slice"};}
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"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/9
@_ > 1 and defined $_[0] and builtin::blessed($_[0]) || $_[0] eq __PACKAGE__
@_ > 1 and defined $_[0]
builtin::blessed($_[0]) or $_[0] eq __PACKAGE__
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__
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | die "Hyperdrive blob requires exactly one byte string\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%3/9
defined $sql and not ref $sql and $sql =~ /\S/u and index($sql, "\0") == -1
defined $sql and not ref $sql and $sql =~ /\S/u
defined $sql and not ref $sql
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | ▶ | $root_or->{'opening'}=$root_or->{'transport'}->call('open') unless $root_or->{'opening'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
defined $opened_hr->{"connection"} and not ref $opened_hr->{"connection"} and length $opened_hr->{"connection"}
defined $opened_hr->{"connection"} and not ref $opened_hr->{"connection"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$self->{"root"} and not $self->{"active"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 48 | ▶ | $opt{'owner'}=$self->{'owner'} if $self->{'root'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
@_ == 2 and ref $callback_cr eq "CODE"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 11 | ▶ | die "Nested Hyperdrive transactions are unsupported\n" if $self->{'transaction'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 10 | ▶ | die "Await earlier Hyperdrive operations before starting a transaction callback\n" if $self->{'pending'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
defined $begun_hr->{"owner"} and not ref $begun_hr->{"owner"} and length $begun_hr->{"owner"}
defined $begun_hr->{"owner"} and not ref $begun_hr->{"owner"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
builtin::blessed($callback_or) and $callback_or->isa("Future")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 9 | $value_ref=await $callback_or; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | ▶ | die "Hyperdrive transaction callback left unfinished operations\n" if $facade_or->{'pending'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 9 | my $error_ref=$@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 9 | $facade_or->{'active'}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 9 | ▶ | if ($ok_fg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 4 | ▶ | delete($self->{'owner'}) if $ok_fg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 9 | ▶ | if (!$ok_fg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 6 | ▶ | unless (blessed($error_ref)&&$error_ref->isa('WebDyne::Cloudflare::Hyperdrive::Error')&&$error_ref->outcome_unknown()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
builtin::blessed($error_ref) and $error_ref->isa("WebDyne::Cloudflare::Hyperdrive::Error") and $error_ref->outcome_unknown
builtin::blessed($error_ref) and $error_ref->isa("WebDyne::Cloudflare::Hyperdrive::Error")
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$self->{"root"} or $self->{"managed"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 8 | ▶ | die "Hyperdrive disconnect takes no arguments\n" unless @_==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 8 | ▶ | return $self->{'disconnecting'} if $self->{'disconnecting'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$self->{"connection"} or $self->{"opening"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 6 | ▶ | await $self->request('disconnect', (defined($self->{'owner'}) ? (owner => $self->{'owner'}) : ())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 7 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||