I might be thinking totaly wrong but the reason I'm thinking inheritance is that I have lots of code using plain DBI. With inheritance I'd only need to change the use DBI and $dbh = DBI->connect.
The only thing (hopefully) I really need to know to get this working is how DBD::mysql does the reconnect (or what it calls) since it can realize the connection is lost and can try to reconnect transparent to the script. Basicly what it does today is:
$sth = $dbh->prepare ($sql);
# im doing a mysql restart
$sth->execute (); # DBD::mysql magically reconnects keeping the prepar
+ed statement and executes
While (in case of stoped db):
$sth= $dbh->prepare ($sql);
# stoping mysql
$sth->execute (); # DBD::mysql tries, but no connection, reconnecting
+and trying again will lose the $dbh->prepare
So the way I see it it should be a sane and nice way of doing it:
$sth= $dbh->prepare ($sql);
# stoping mysql
$sth->execute (); # entering reconnect mode in MyDBI::st/db:
while (!$dbh->ping) {
sleep 5;
MyDBI->connect_like_mysql_reconnects;
}
Prefarable giving arguments like { reconnect_tries => 10, wait_time => 5 } so the scripts can configure themselves how long they are prepared to wait.
I guess it all boils down to that I think DBI should be responsible for really trying to reconnect and me not having to surround all my db calls with evals, pings and reconnects ...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.