blib/lib/Lemonldap/NG/Common/Lib/DBI.pm

filter: Statementstmt 100% 16 / 16 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 95.8% 23 / 24 CC 3 SCAR 7.9
CC
3
Cov
100%
check_dbh
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« blib/lib/Lemonldap/NG/Common/Logger/_Duplicate.pm ↑ Summary blib/lib/Lemonldap/NG/Common/Conf/Backends/JSONFile.pm »
1 package Lemonldap::NG::Common::Lib::DBI;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 our $VERSION = '2.22.2';
7 4 our @EXPORT_OK = qw(check_dbh);
8  
9 # Check if a DBI handle is still valid
10 # Returns the handle if valid, undef otherwise
11 # Also cleans up the handle if it's dead (can happen after Patroni failover)
12 60 ▶sub check_dbh {
Subroutine check_dbh: called CC=3 SCAR=11.0
Pod undocumented
13 60 my ($dbh) = @_;
14 60 ▶ return unless $dbh;
Branch: 1 branch
BranchTrueFalseTotal
unless $dbh 15 45 60
15 45 ▶ return $dbh if eval { $dbh->ping };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $dbh->ping } } 39 6 45
16  
17 # Connection is dead, clean up
18 6 eval { $dbh->disconnect };
19 6 return;
20 }
21  
22 4 1;
« blib/lib/Lemonldap/NG/Common/Logger/_Duplicate.pm ↑ Summary blib/lib/Lemonldap/NG/Common/Conf/Backends/JSONFile.pm »