=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
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;
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
$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);
}
}
=cut
+__PACKAGE__->meta->make_immutable;
+
1;