DBIx::Retry - DBIx::Connector with the ability to retry the run method for a specified amount of time.
version 0.004
use DBIx::Retry; my $conn = DBIx::Retry->new($dsn, $user, $tools, {retry_time => 5}); # all other method are inherited from DBIx::Connector my $dbh = $conn->dbh; #get a database handle # Do something with the handle - will retry for specified amount of time, should the database connection be lost $conn->run(fixup => sub { $_->do('INSERT INTO foo (name) VALUES (?)', undef, 'Fred' ); });
DBIx::Retry is extended from DBIx::Connector. It adds the ability to keep retrying to connect to a database for a specified amount of time in order to execute DBIx::Connector's run method.
Amount of seconds to retry re-connecting to database, should the database become unavailable.
Enable verbose output.
Create a new DBIx::Retry object. my $conn = DBIx::Retry->new($dsn, $user, $tools,{timeout => 5, verbose => 1});
Simply create a new DBIx::Retry object:
my $conn = DBIx::Retry->new($dsn, $user, $tools, {retry_time => 5});
Then wrap your operations inside the run method that is inherited from DBIx::Connector:
$conn->run(fixup => sub { $_->do('INSERT INTO foo (name) VALUES (?)', undef, 'Fred' ); });
Should the connection to the database be lost then DBIx::Retry will retry to connect to the database for the amount of seconds specified in the "retry_time" attribute.
DBIx::Connector
Hartmut Behrens <hartmut.behrens@gmail.com>
This software is copyright (c) 2012 by Hartmut Behrens.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install DBIx::Retry, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Retry
CPAN shell
perl -MCPAN -e shell install DBIx::Retry
For more information on module installation, please visit the detailed CPAN module installation guide.