[Bast-commits] r4369 - in
DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI:
. Replicated
jnapiorkowski at dev.catalyst.perl.org
jnapiorkowski at dev.catalyst.perl.org
Fri May 9 01:31:58 BST 2008
Author: jnapiorkowski
Date: 2008-05-09 01:31:58 +0100 (Fri, 09 May 2008)
New Revision: 4369
Modified:
DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated.pm
DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm
Log:
fixed up the relicant status tests to exclude them if the database is not a real replicating setup, removed some debug code, got the lag_behind_master and is_replicating methods working properly.
Modified: DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm 2008-05-09 00:06:42 UTC (rev 4368)
+++ DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm 2008-05-09 00:31:58 UTC (rev 4369)
@@ -24,8 +24,27 @@
This class defines the following attributes.
-=head2 replicant_type
+=head2 maximum_lag ($num)
+This is a number which defines the maximum allowed lag returned by the
+L<DBIx::Class::Storage::DBI/lag_behind_master> method. The default is 0. In
+general, this should return a larger number when the replicant is lagging
+behind it's master, however the implementation of this is database specific, so
+don't count on this number having a fixed meaning. For example, MySQL will
+return a number of seconds that the replicating database is lagging.
+
+=cut
+
+has 'maximum_lag' => (
+ is=>'ro',
+ isa=>'Num',
+ required=>1,
+ lazy=>1,
+ default=>0,
+);
+
+=head2 replicant_type ($classname)
+
Base class used to instantiate replicants that are in the pool. Unless you
need to subclass L<DBIx::Class::Storage::DBI::Replicated::Replicant> you should
just leave this alone.
@@ -107,8 +126,6 @@
=cut
-use Data::Dump qw/dump/;
-
sub connect_replicants {
my $self = shift @_;
my $schema = shift @_;
@@ -179,6 +196,31 @@
return values %{$self->replicants};
}
+=head2 validate_replicants
+
+This does a check to see if 1) each replicate is connected (or reconnectable),
+2) that is ->is_replicating, and 3) that it is not exceeding the lag amount
+defined by L</maximum_lag>. Replicants that fail any of these tests are set to
+inactive, and thus removed from the replication pool.
+
+This tests L<all_replicants>, since a replicant that has been previous marked
+as inactive can be reactived should it start to pass the validation tests again.
+
+See L<DBIx::Class::Storage::DBI> for more about checking if a replicating
+connection is not following a master or is lagging.
+
+Calling this method will generate queries on the replicant databases so it is
+not recommended that you run them very often.
+
+=cut
+
+sub validate_replicants {
+ my $self = shift @_;
+ foreach my $replicant($self->all_replicants) {
+
+ }
+}
+
=head1 AUTHOR
John Napiorkowski <john.napiorkowski at takkle.com>
Modified: DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated.pm 2008-05-09 00:06:42 UTC (rev 4368)
+++ DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated.pm 2008-05-09 00:31:58 UTC (rev 4369)
@@ -73,6 +73,18 @@
},
);
+=head2 pool_args
+
+Contains a hashref of initialized information to pass to the Pool object. See
+L<DBIx::Class::Storage::Replicated::Pool> for available arguments.
+
+=cut
+
+has 'pool_args' => (
+ is=>'ro',
+ isa=>'HashRef',
+);
+
=head2 balancer_type
The replication pool requires a balance class to provider the methods for
@@ -258,7 +270,8 @@
=cut
sub _build_pool {
- shift->create_pool;
+ my $self = shift @_;
+ $self->create_pool($self->pool_args);
}
=head2 _build_balancer_type
More information about the Bast-commits
mailing list