X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FReplicated%2FPool.pm;h=6fe704626a35a3bc34d8bb5b64f5fc216ad5bc7b;hb=c354902c20a8459162b76a4006cb6091af5bf6d4;hp=07af406e3fd7a379a7e9de4c61bd1fd4b9ee4919;hpb=64cdad22d9b4022de379ae43174c15ce8dc81b59;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 07af406..6fe7046 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm @@ -149,10 +149,7 @@ sub connect_replicants { my @newly_created = (); foreach my $connect_info (@_) { - my $replicant = $self->create_replicant($schema); - $replicant->connect_info($connect_info); - $replicant->ensure_connected; - DBIx::Class::Storage::DBI::Replicated::Replicant->meta->apply($replicant); + my $replicant = $self->connect_replicant($schema, $connect_info); my ($key) = ($connect_info->[0]=~m/^dbi\:.+\:(.+)$/); $self->set_replicant( $key => $replicant); push @newly_created, $replicant; @@ -161,6 +158,24 @@ sub connect_replicants { return @newly_created; } +=head2 connect_replicant ($schema, $connect_info) + +Given a schema object and a hashref of $connect_info, connect the replicant +and return it. + +=cut + +sub connect_replicant { + my ($self, $schema, $connect_info) = @_; + my $replicant = $self->create_replicant($schema); + + $replicant->connect_info($connect_info); + $replicant->ensure_connected; + DBIx::Class::Storage::DBI::Replicated::Replicant->meta->apply($replicant); + + return $replicant; +} + =head2 connected_replicants Returns true if there are connected replicants. Actually is overloaded to @@ -237,10 +252,8 @@ sub validate_replicants { $replicant->lag_behind_master <= $self->maximum_lag && $replicant->ensure_connected ) { - ## TODO:: Hook debug for this $replicant->active(1) } else { - ## TODO:: Hook debug for this $replicant->active(0); } } @@ -258,4 +271,6 @@ You may distribute this code under the same terms as Perl itself. =cut +__PACKAGE__->meta->make_immutable; + 1;