« 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
| |||||||||||
| 15 | 45 | ▶ | return $dbh if eval { $dbh->ping }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | |||||||||||
| 17 | # Connection is dead, clean up | ||||||||||
| 18 | 6 | eval { $dbh->disconnect }; | |||||||||
| 19 | 6 | return; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 4 | 1; | |||||||||