Update of /cvs/scoop/scoop/lib
In directory lithium.sabren.com:/tmp/cvs-serv31385/lib
Modified Files:
Scoop.pm
Log Message:
In preparation for Scoop 1.2's eventual release, committing support for master and slave databases. -j
Index: Scoop.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop.pm,v
retrieving revision 1.145
retrieving revision 1.146
diff -C2 -d -r1.145 -r1.146
*** Scoop.pm 26 Apr 2006 20:56:47 -0000 1.145
--- Scoop.pm 27 Apr 2006 03:52:47 -0000 1.146
***************
*** 993,996 ****
--- 993,1039 ----
$self->{HAVE_ARCHIVE} = 0;
}
+ # That's not funny. I was a slave!
+ $dbname = $self->CONFIG->{db_name_slave};
+ $username = $self->CONFIG->{db_user_slave};
+ $password = $self->CONFIG->{db_pass_slave};
+ $dbhost = $self->CONFIG->{db_host_slave};
+ if($dbhost){
+ my @slaves = split /,/, $dbhost;
+ for (my $s = 0; $s <= $#slaves; $s++){
+ $data_source = "DBI:$dbtype:dbname=$dbname;host=$slaves[$s]";
+ $dbh = DBI->connect($data_source, $username, $password)
+ ||
+ warn " (Scoop::_set_dbh) Can't connect to slave database! $@\n";
+ $self->{SLAVEDB}->[$s] = $dbh;
+ warn "connect to slave SLAVEDB $s\n";
+ }
+ $self->{HAVE_SLAVE} = 1;
+ $self->{NUMSLAVES} = $#slaves + 1;
+ }
+ else {
+ $self->{HAVE_SLAVE} = 0;
+ }
+ # And set up the archive db slaves as well, if we decide we want some.
+ $dbname = $self->CONFIG->{db_name_slave_arch};
+ $username = $self->CONFIG->{db_user_slave_arch};
+ $password = $self->CONFIG->{db_pass_slave_arch};
+ $dbhost = $self->CONFIG->{db_host_slave_arch};
+ if($dbhost){
+ my @slaves = split /,/, $dbhost;
+ for (my $s = 0; $s <= $#slaves; $s++){
+ $data_source = "DBI:$dbtype:dbname=$dbname;host=$slaves[$s]";
+ $dbh = DBI->connect($data_source, $username, $password)
+ ||
+ warn " (Scoop::_set_dbh) Can't connect to slave database! $@\n";
+ $self->{SLAVEARCHDB}->[$s] = $dbh;
+ warn "connect to slave SLAVEARCHDB $s\n";
+ }
+ $self->{HAVE_SLAVE_ARCHIVE} = 1;
+ $self->{NUMARCHSLAVES} = $#slaves + 1;
+ }
+ else {
+ $self->{HAVE_SLAVE_ARCHIVE} = 0;
+ }
+
return $self;