Branch Coverage

blib/lib/Async/Redis.pm
Criterion Covered Total %
branch 117 428 27.3


line true false branch
54 0 91 unless eval { do { require Protocol::Redis::XS; 1 } }
59 0 0 $INC{'Protocol/Redis/XS.pm'} ? :
69 1 2 if $delay > $self->{'reconnect_delay_max'}
72 0 3 if ($self->{'reconnect_jitter'} > 0)
93 1 4 unless (defined $deadline)
98 1 3 if ($remaining <= 0)
110 1 2 $f->is_failed && (($f->failure)[0] // '') eq '__deadline__' ? :
113 0 2 unless ($timed_out or $timeout_f->is_ready)
125 2 107 if ($args{'uri'})
128 2 0 if ($uri)
191 2 107 if $d < 1
218 4 105 $args{'path'} ? :
4 105 $args{'path'} ? :
222 0 107 if ($self->{'debug'} or $self->{'otel_tracer'} or $self->{'otel_meter'})
242 0 78 if $self->{'connected'}
247 1 77 if ($self->{'path'}) { }
252 0 1 unless socket $socket, 1, 1, 0
264 0 77 unless $socket = "IO::Socket::INET"->new("Proto", "tcp", "Blocking", 0)
272 0 77 unless my $addr = inet_aton($self->{'host'})
295 78 0 if ($completed_f->is_failed)
300 0 78 if ($error eq "connect_timeout")
314 0 0 if ($self->{'tls'})
318 0 0 if ($@)
336 0 0 unless ($handshake_ok)
345 0 0 if ($self->{'auto_pipeline'})
353 0 0 if ($self->{'on_connect'})
359 0 0 if ($self->{'_telemetry'})
377 0 0 if (defined $self->{'password'})
379 0 0 if defined $self->{'username'}
389 0 0 unless ($result and $result eq "OK")
398 0 0 if ($self->{'database'} and $self->{'database'} != 0)
405 0 0 unless ($result and $result eq "OK")
414 0 0 if (defined $self->{'client_name'} and length $self->{'client_name'})
426 0 0 $self->{'connected'} ? :
451 0 0 unless $self->{'_socket_live'} or $self->{'connected'}
458 0 0 if (my $sub = $self->{'_subscription'})
459 0 0 unless $sub->is_closed
468 0 0 if (my $ap = $self->{'_auto_pipeline'})
474 0 0 if ($self->{'_current_read_future'} and not $self->{'_current_read_future'}->is_ready)
483 0 0 if (my $rf = delete $self->{'_reconnect_future'})
484 0 0 unless $rf->is_ready
497 0 0 if (my $lock = delete $self->{'_write_lock'})
498 0 0 unless $lock->is_ready
501 0 0 if $self->{'socket'}
512 0 0 if $entry->{'future'}->is_ready
519 0 0 if ($was_connected and $self->{'on_disconnect'})
522 0 0 if ($was_connected and $self->{'_telemetry'})
534 0 104 if ($self->{'socket'} and fileno $self->{'socket'})
544 0 0 unless my $socket = delete $self->{'socket'}
550 0 0 if (my $inflight = delete $self->{'inflight'})
552 0 0 if ($entry->{'future'} and not $entry->{'future'}->is_ready)
560 0 0 if defined $fileno
572 0 2 if ($self->{'_pid'} and $self->{'_pid'} != $$)
586 0 0 if ($self->{'_telemetry'})
604 0 3 if utf8::is_utf8($bytes)
644 0 0 if ($entry->{'future'} and not $entry->{'future'}->is_ready)
659 0 0 unless $self->{'_socket_live'}
660 0 0 unless $self->{'in_pubsub'} or @{$self->{'inflight'};}
661 0 0 if $self->{'in_pubsub'} and not $self->{'_subscription'}
664 0 0 $head ? :
674 0 0 if not $timed_out and $returned_f->is_ready and not $returned_f->is_failed
676 0 0 if ($timed_out)
681 0 0 $head ? :
687 0 0 if ($returned_f->is_failed)
699 0 0 if (not defined $buf or length $buf == 0)
715 0 0 if ($kind eq "protocol_error")
721 0 0 if ($self->{'in_pubsub'} and $kind eq "ok" and ref $value eq "ARRAY")
723 0 0 if $frame_name eq "message" or $frame_name eq "pmessage" or $frame_name eq "smessage"
729 0 0 if ($is_pubsub_message)
731 0 0 unless ($sub)
744 0 0 if (builtin::blessed($dispatch_result) and $dispatch_result->isa("Future"))
750 0 0 unless (@{$self->{'inflight'};})
761 0 0 if ($kind eq 'redis_error') { }
762 0 0 if (($entry->{'redis_error'} // 'fail') eq 'capture') { }
763 0 0 unless $entry->{'future'}->is_ready
765 0 0 unless $entry->{'future'}->is_ready
768 0 0 unless $entry->{'future'}->is_ready
788 0 0 if $self->{'_reader_running'}
802 0 0 if (my $msg = $self->{'parser'}->get_message)
811 0 0 if (not defined $buf or length $buf == 0)
817 0 0 if (my $msg = $self->{'parser'}->get_message)
850 3 11 unless ($spec)
857 5 6 if ($pos eq 'last') { }
3 3 elsif ($pos eq 'block_option') { }
862 2 2 if (uc($args[$i] // "") eq "BLOCK")
869 1 2 unless defined $raw
876 1 9 unless (defined $raw and $raw =~ /^-?\d+(?:\.\d+)?$/u)
881 4 5 ($spec->{'unit'} // 'seconds') eq 'ms' ? :
886 3 6 if $seconds == 0
910 3 2 ref $tls eq 'HASH' ? :
912 1 4 exists $tls_hash->{'verify'} ? :
913 1 4 exists $tls_hash->{'verify_hostname'} ? :
915 1 4 if $tls_hash->{'ca_file'}
916 1 4 if $tls_hash->{'cert_file'}
917 1 4 if $tls_hash->{'key_file'}
919 4 1 if ($verify) { }
923 3 1 if ($verify_hostname)
948 0 0 unless "IO::Socket::SSL"->start_SSL($socket, %ssl_opts)
955 0 0 if (&Time::HiRes::time() >= $deadline)
965 0 0 if ($rv)
972 0 0 if $remaining <= 0
974 0 0 if ($IO::Socket::SSL::SSL_ERROR == IO::Socket::SSL::SSL_ERROR_WANT_READ()) { }
0 0 elsif ($IO::Socket::SSL::SSL_ERROR == IO::Socket::SSL::SSL_ERROR_WANT_WRITE()) { }
984 0 0 if ($wait_f->is_failed)
1001 0 0 if ($wait_f->is_failed)
1035 2 6 if ($ok)
1043 0 6 if ($self->{'on_error'})
1049 3 3 if ($max and $attempt >= $max)
1080 0 0 if $self->{'_socket_live'}
1081 0 0 if (my $f = $self->{'_reconnect_future'})
1097 0 1 unless my $sub = $self->{'_subscription'}
1137 0 0 if $self->{'_reconnect_future'} and not $self->{'_reconnect_future'}->is_ready
1153 0 0 if ($weak_sub)
1164 0 0 unless $weak_self
1169 0 0 unless $weak_sub
1184 0 2 if ($self->{'in_pubsub'})
1186 0 0 unless ($ucmd =~ /^(SUBSCRIBE|UNSUBSCRIBE|PSUBSCRIBE|PUNSUBSCRIBE|SSUBSCRIBE|SUNSUBSCRIBE|PING|QUIT)$/u)
1194 0 2 if (defined $self->{'prefix'} and $self->{'prefix'} ne "")
1201 0 2 if ($self->{'_auto_pipeline'})
1208 0 2 if ($self->{'_telemetry'})
1224 2 0 unless ($self->{'_socket_live'})
1225 0 2 if ($self->_reconnect_enabled) { }
1241 2 0 if (not $submit_ok) { }
1254 0 0 unless ($await_ok)
1258 0 2 if ($self->{'_telemetry'})
1260 0 0 if ($error) { }
1269 2 0 if $error
1278 0 0 if (my $msg = $self->{'parser'}->get_message)
1286 0 0 if ($remaining <= 0)
1313 0 0 if ($read_f->is_cancelled)
1319 0 0 if ($wait_f->is_failed)
1321 0 0 if ($error eq "read_timeout")
1340 0 0 if (not defined $buf or length $buf == 0)
1349 0 0 if (my $msg = $self->{'parser'}->get_message)
1364 0 2 if ($self->{'_current_read_future'} and not $self->{'_current_read_future'}->is_ready)
1370 2 0 if (my $inflight = $self->{'inflight'})
1372 0 0 if ($entry->{'future'} and not $entry->{'future'}->is_ready)
1379 0 2 if ($self->{'socket'})
1391 0 1 if ($was_connected and $self->{'on_disconnect'})
1425 5 0 if $f and not $f->is_ready
1436 2 0 unless ($ok)
1444 2 0 ref $err && eval { do { $err->isa('Async::Redis::Error') } } ? :
1464 1 9 if $self->{'_fatal_in_progress'}
1479 1 8 if (my $ap = $self->{'_auto_pipeline'})
1484 0 9 if ($self->{'_current_read_future'} and not $self->{'_current_read_future'}->is_ready)
1491 0 9 if $self->{'socket'}
1500 0 3 if $entry->{'future'}->is_ready
1508 0 9 if ($was_pubsub and $subscription)
1509 0 0 if ($self->_reconnect_enabled and $subscription->can('_pause_for_reconnect')) { }
0 0 elsif ($subscription->can('_fail_fatal')) { }
1512 0 0 if ($self->can("_reconnect_async"))
1521 0 0 if $subscription->can("_close")
1526 4 2 if ($was_connected and $self->{'on_disconnect'})
1536 1 8 if not $ok and $caught
1543 0 0 unless $msg
1549 0 0 if ($type eq '+') { }
0 0 elsif ($type eq '-') { }
0 0 elsif ($type eq ':') { }
0 0 elsif ($type eq '$') { }
0 0 elsif ($type eq '*') { }
1566 0 0 unless defined $data
1581 1 13 unless (defined $msg)
1590 3 10 if ($type eq '+') { }
2 8 elsif ($type eq '-') { }
3 5 elsif ($type eq ':') { }
2 3 elsif ($type eq '$') { }
2 1 elsif ($type eq '*') { }
1603 0 2 unless defined $data
1607 0 5 if ($k eq "protocol_error")
1633 0 0 if exists $opts{'ex'}
1634 0 0 if exists $opts{'px'}
1635 0 0 if $opts{'nx'}
1636 0 0 if $opts{'xx'}
1702 0 0 if $mode
1720 0 0 if ($@)
1724 0 0 if ("$error" =~ /NOSCRIPT/iu) { }
1750 0 0 unless defined $name and length $name
1751 0 0 unless ref $def eq "HASH"
1752 0 0 unless defined $def->{'lua'}
1754 0 0 if exists $def->{'install'}
1757 0 0 unless $name =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/u
1779 0 0 unless my $script = $self->{'_scripts'}{$name}
1785 0 0 if ($num_keys eq "dynamic")
1787 0 0 unless defined $num_keys
1814 0 0 unless @names
1881 0 0 if $self->{'in_multi'}
1898 0 0 if ($collect_error)
1904 0 0 unless (@commands)
1936 0 0 if ($error)
1955 0 2 if $self->{'in_multi'}
1956 0 2 if $self->{'watching'}
1957 0 2 if $self->{'in_pubsub'}
1958 0 2 if @{$self->{'inflight'} // [];} > 0
2028 0 0 if (@commands) { }
2050 0 0 unless ($ok)
2051 0 0 if ($multi_started) { }
0 0 elsif ($watch_active) { }
2079 0 0 unless @{$self->{'inflight'};}
2087 0 0 if (@{$self->{'inflight'};})
2108 0 0 unless $self->{'connected'}
2114 0 0 if ($self->{'_subscription'} and $self->{'_subscription'}->is_closed)
2142 0 0 unless $self->{'connected'}
2148 0 0 if ($self->{'_subscription'} and $self->{'_subscription'}->is_closed)
2170 0 0 unless $self->{'connected'}
2176 0 0 if ($self->{'_subscription'} and $self->{'_subscription'}->is_closed)
2198 1 0 unless $self->{'connected'}
2222 0 0 unless ($self->{'_socket_live'})
2235 0 0 unless ($submit_ok)
2278 0 0 unless @$commands
2295 0 0 unless ($self->{'_socket_live'})
2296 0 0 if ($self->_reconnect_enabled) { }
2324 0 0 if $ok
2331 0 0 unless $r_ok
2336 0 0 if ($self->{'_telemetry'})