HealthCheck::Diagnostic::DBHCheck - Check a database handle to make sure you have read/write access
version v1.0.1
my $health_check = HealthCheck->new( checks => [
HealthCheck::Diagnostic::DBHCheck->new(
dbh => \&connect_to_read_write_db,
db_access => "rw",
tags => [qw< dbh_check_rw >]
timeout => 10, # default
),
HealthCheck::Diagnostic::DBHCheck->new(
dbh => \&connect_to_read_only_db,
db_access => "ro",
tags => [qw< dbh_check_ro >]
),
] );
my $result = $health_check->check;
$result->{status}; # OK on a successful check or CRITICAL otherwise
Determines if the database can be used for read and write access, or read only access.
For read access, a simple SELECT statement is used.
For write access, a temporary table is created, and used for testing.
Those inherited from "ATTRIBUTES" in HealthCheck::Diagnostic plus:
Inherited from "label" in HealthCheck::Diagnostic,
defaults to dbh_check
.
Inherited from "tags" in HealthCheck::Diagnostic,
defaults to [ 'dbh_check' ]
.
A coderef that returns a DBI DATABASE handle object or optionally the handle itself.
Can be passed either to new
or check
.
A string indicating the type of access being tested.
A value of ro
indicates only read access shoud be tested.
A value of rw
indicates both read and write access should be tested.
DEFAULT is rw
.
The expected class for the database handle returned by the dbh
coderef.
Defaults to DBI::db
.
Sets up an ALRM
signal handler used to timeout the initial connection
attempt after the number of seconds provided.
Defaults to 10.
None
Grant Street Group developers@grantstreet.com
This software is Copyright (c) 2019 - 2023 by Grant Street Group.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)