TryAgain.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 22 / 22 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« TryAgain/db.pm ↑ Summary
1 =head1 NAME
2  
3 DBIx::TryAgain - If at first you don't succeed, try DBIx::TryAgain.
4  
5 =head1 SYNOPSIS
6  
7 my $dbh = DBIx::TryAgain->connect(...) or die $DBI::errstr;
8  
9 OR
10  
11 my $dbh = DBI->connect(... dbi params.. { RootClass => "DBIx::TryAgain" } ) or die $DBI::errstr;
12  
13 $dbh->try_again_algorithm('fibonacci');
14 $dbh->try_again_max_retries(5);
15 $dbh->try_again_on_messages([ qr/database is locked/i ]);
16 $dbh->try_again_on_prepare(1);
17  
18 =head1 DESCRIPTION
19  
20 This is a subclass of DBI which simply tries to execute a query
21 again whenever the error string matches a given set of patterns.
22  
23 By default the only pattern is qr[database is locked], which is
24 what is returned by SQLite when the database is locked.
25  
26 There is a delay between retries. Setting try_again_algorithm
27 to 'constant', 'linear', 'fibonacci', or 'exponential' causes
28 the corresponding algorithm to be used. The first five
29 values for these algorithsm are :
30  
31 constant : 1,1,1,1,1
32 linear : 1,2,3,4,5
33 fibonacci : 1,1,2,3,5
34 exponential : 1,2,4,8,16
35  
36 Modify the PrintError attribute and DBI_TRACE environment (as with
37 DBI) to change the level of verbosity of this module.
38  
39 In addition to retrying an execute(), DBIx::TryAgain and also
40 retry a prepare statement, by calling $dbh->try_again_on_prepare(1);
41  
42 =head1 AUTHOR
43  
44 Brian Duggan, C<< <bduggan at matatu.org> >>
45  
46 =head1 SEE ALSO
47  
48 L<DBI>
49  
50 =head1 TODO
51  
52 Support error codes as well as messages.
53  
54 =cut
55  
56 package DBIx::TryAgain;
57  
58 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 3 our $VERSION = '0.05';
62  
63 3 ▶use DBI ( );
Subroutine BEGIN: called CC=1 SCAR=0.0
64 3 ▶use DBIx::TryAgain::st;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 3 ▶use DBIx::TryAgain::db;
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 3 our @ISA = 'DBI';
68  
« TryAgain/db.pm ↑ Summary