X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FReplicated%2FPool.pm;h=513752a03787606980b32f15615eecfa3fbfa0e4;hb=503363253e1fa2c35e3b5368dd7f453b9cfbc6a1;hp=3bf1ac8b55b188174dc329534d14d02d4f14e162;hpb=26ab719a4d6ee414537c815677b9884b64417539;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm index 3bf1ac8..513752a 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm @@ -101,7 +101,7 @@ has 'replicants' => ( This class defines the following methods. -=head2 create_replicants (Array[$connect_info]) +=head2 create_replicants ($schema, Array[$connect_info]) Given an array of $dsn suitable for connected to a database, create an L object and store it in the @@ -111,10 +111,11 @@ L attribute. sub create_replicants { my $self = shift @_; + my $schema = shift @_; my @newly_created = (); foreach my $connect_info (@_) { - my $replicant = $self->create_replicant; + my $replicant = $self->create_replicant($schema); $replicant->connect_info($connect_info); $replicant->ensure_connected; my ($key) = ($connect_info->[0]=~m/^dbi\:.+\:(.+)$/); @@ -149,6 +150,21 @@ sub connected_replicants { } $self->all_replicants ); } +=head2 active_replicants + +This is an array of replicants that are considered to be active in the pool. +This does not check to see if they are connected, but if they are not, DBIC +should automatically reconnect them for us when we hit them with a query. + +=cut + +sub active_replicants { + my $self = shift @_; + return ( grep {$_} map { + $_->active ? $_:0 + } $self->all_replicants ); +} + =head2 all_replicants Just a simple array of all the replicant storages. No particular order to the