Subject: | BAGGAGE not a valid argument for CONNECT |
To be fair 'BAGGAGE' is not listed in the accepted arguments for
'CONNECT'. However, if POE::Component::SimpleDBI::DEBUG is not enabled
you get no warning that BAGGAGE was ignored.
Ideally I'd like to see BAGGAGE as an accepted argument for CONNECT.
If that isn't reasonable I think SimpleDBI should warn all the time and
not just when DEBUG is enabled.
Having BAGGAGE as an accepted argument would facility building a pool of
DBI connections.
Attached is a trival script to replicate the issue
Subject: | dbi-simple.pl |
#!/usr/bin/perl
use warnings;
use strict;
# sub POE::Component::SimpleDBI::DEBUG { 1 }
sub DB_NAME () { "test" }
sub DB_USER () { "user" }
sub DB_PASS () { "password" }
use POE;
use POE::Component::SimpleDBI ();
use Data::Dumper;
# Create the session that will do transactions.
POE::Session->create(
inline_states => {
_start => \&start_session,
DB_connected => \&DB_connected,
}
);
$poe_kernel->run();
exit 0;
sub start_session {
my ($kernel, $heap) = @_[KERNEL, HEAP];
my ($host, $port, $name) = qw(localhost 3306 SimpleDBI);
warn "connect... $name\n";
POE::Component::SimpleDBI->new( $name );
$_[KERNEL]->post( $name, 'CONNECT',
DSN => "DBI:mysql:database=test;host=$host;port=$port",
USERNAME => DB_USER,
PASSWORD => DB_PASS,
EVENT => 'DB_connected',
NOW => 1,
BAGGAGE => ["$name"],
);
}
sub DB_connected {
if ($_[ARG0]->{ERROR}) {
warn 'DBI : connection failed';
} else {
warn Dumper ($_[ARG0]);
my $name = $_[ARG0]->{BAGGAGE}->[0];
if (defined $name) {
$_[KERNEL]->post( $name, 'shutdown');
} else {
warn "BAGGAGE unexpectedly empty!" unless $name;
$_[KERNEL]->post( 'SimpleDBI', 'shutdown');
}
}
};