X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FReplicated%2FPool.pm;h=7c82d28c12da85f40839f1aedf09acaef97d0aa3;hb=ddcc02d14d03169c54c65db9f0f446836483ba55;hp=a9f379306afc555cfaa4adc5bfc136de003b82d9;hpb=9780718f9c36738245f90b1f036998c3b076cffc;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 a9f3793..7c82d28 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm @@ -5,9 +5,9 @@ use DBIx::Class::Storage::DBI::Replicated::Replicant; use List::Util 'sum'; use Scalar::Util 'reftype'; use DBI (); -use Carp::Clan qw/^DBIx::Class/; use MooseX::Types::Moose qw/Num Int ClassName HashRef/; use DBIx::Class::Storage::DBI::Replicated::Types 'DBICStorageDBI'; +use DBIx::Class::_Util 'dbic_internal_try'; use Try::Tiny; use namespace::clean -except => 'meta'; @@ -24,7 +24,7 @@ shouldn't need to create instances of this class. =head1 DESCRIPTION In a replicated storage type, there is at least one replicant to handle the -read-only traffic. The Pool class manages this replicant, or list of +read-only traffic. The Pool class manages this replicant, or list of replicants, and gives some methods for querying information about their status. =head1 ATTRIBUTES @@ -82,7 +82,7 @@ has 'replicant_type' => ( default=>'DBIx::Class::Storage::DBI', handles=>{ 'create_replicant' => 'new', - }, + }, ); =head2 replicants @@ -220,7 +220,7 @@ sub connect_replicants { } $replicant->id($key); - $self->set_replicant($key => $replicant); + $self->set_replicant($key => $replicant); push @newly_created, $replicant; } @@ -294,18 +294,16 @@ Returns 1 on success and undef on failure. sub _safely { my ($self, $replicant, $name, $code) = @_; - my $rc = 1; - try { - $code->() + return dbic_internal_try { + $code->(); + 1; } catch { $replicant->debugobj->print(sprintf( "Exception trying to $name for replicant %s, error is %s", $replicant->_dbi_connect_info->[0], $_) ); - $rc = undef; + undef; }; - - return $rc; } =head2 connected_replicants @@ -365,7 +363,7 @@ This does a check to see if 1) each replicate is connected (or reconnectable), defined by L. Replicants that fail any of these tests are set to inactive, and thus removed from the replication pool. -This tests L, since a replicant that has been previous marked +This tests L, since a replicant that has been previous marked as inactive can be reactivated should it start to pass the validation tests again. See L for more about checking if a replicating @@ -398,9 +396,9 @@ sub validate_replicants { if($lag_behind_master <= $self->maximum_lag) { $replicant->active(1); } else { - $replicant->active(0); + $replicant->active(0); } - } + } } else { $replicant->active(0); } @@ -409,17 +407,20 @@ sub validate_replicants { $replicant->active(0); } } - ## Mark that we completed this validation. - $self->_last_validated(time); + ## Mark that we completed this validation. + $self->_last_validated(time); } -=head1 AUTHOR +=head1 FURTHER QUESTIONS? -John Napiorkowski +Check the list of L. -=head1 LICENSE +=head1 COPYRIGHT AND LICENSE -You may distribute this code under the same terms as Perl itself. +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L. =cut