X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FReplicated%2FPool.pm;h=b1cdc821713f6e34043597235cfd241f5ba5cb1e;hb=21fc471939bf782a3ae38f8c71a4563fe50592d3;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..b1cdc82 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm @@ -7,7 +7,7 @@ use List::Util qw(sum); =head1 NAME -DBIx::Class::Storage::DBI::Replicated::Pool; Manage a pool of replicants +DBIx::Class::Storage::DBI::Replicated::Pool - Manage a pool of replicants =head1 SYNOPSIS @@ -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;