=cut
has 'maximum_lag' => (
- is=>'ro',
+ is=>'rw',
isa=>'Num',
required=>1,
lazy=>1,
default=>0,
);
+=head2 last_validated
+
+This is an integer representing a time since the last time the replicants were
+validated. It's nothing fancy, just an integer provided via the perl time
+builtin.
+
+=cut
+
+has 'last_validated' => (
+ is=>'rw',
+ isa=>'Int',
+ reader=>'last_validated',
+ writer=>'_last_validated',
+ lazy=>1,
+ default=>sub {
+ 0;
+ },
+);
+
=head2 replicant_type ($classname)
Base class used to instantiate replicants that are in the pool. Unless you
=cut
sub all_replicants {
- my $self = shift @_;
- return values %{$self->replicants};
+ my $self = shift @_;
+ return values %{$self->replicants};
}
=head2 validate_replicants
=cut
sub validate_replicants {
- my $self = shift @_;
- foreach my $replicant($self->all_replicants) {
-
- }
+ my $self = shift @_;
+ foreach my $replicant($self->all_replicants) {
+ if(
+ $replicant->is_replicating &&
+ $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);
+ }
+ }
+
+ ## Mark that we completed this validation.
+ $self->_last_validated(time);
}
=head1 AUTHOR