package DBIx::Class::Storage::DBI::Replicated::Balancer;
-use Moose::Role;
+use Moo::Role;
+use Scalar::Util ();
+use DBIx::Class::Storage::DBI::Replicated::Types
+ qw(PositiveInteger DBICStorageDBI DBICStorageDBIReplicatedPool);
+
requires 'next_storage';
-use MooseX::Types::Moose qw/Int/;
-use DBIx::Class::Storage::DBI::Replicated::Pool;
-use DBIx::Class::Storage::DBI::Replicated::Types qw/DBICStorageDBI/;
-use namespace::clean -except => 'meta';
=head1 NAME
has 'auto_validate_every' => (
is=>'rw',
- isa=>Int,
+ isa=>PositiveInteger,
predicate=>'has_auto_validate_every',
+
);
=head2 master
has 'pool' => (
is=>'ro',
- isa=>'DBIx::Class::Storage::DBI::Replicated::Pool',
+ isa=>DBICStorageDBIReplicatedPool,
required=>1,
);
has 'current_replicant' => (
is=> 'rw',
isa=>DBICStorageDBI,
- lazy_build=>1,
+ lazy=>1,
+ builder=>'_build_current_replicant',
handles=>[qw/
select
select_single
=cut
sub _build_current_replicant {
- my $self = shift @_;
+ my $self = shift;
$self->next_storage;
}
that it's easier to break out the auto validation into a role.
This also returns the master in the case that none of the replicants are active
-or just just forgot to create them :)
+or just just for?blgot to create them :)
=cut
=cut
sub increment_storage {
- my $self = shift @_;
+ my $self = shift;
my $next_replicant = $self->next_storage;
$self->current_replicant($next_replicant);
}
=cut
before 'columns_info_for' => sub {
- my $self = shift @_;
+ my $self = shift;
$self->increment_storage;
};
sub _get_forced_pool {
my ($self, $forced_pool) = @_;
- if(blessed $forced_pool) {
+ if(Scalar::Util::blessed($forced_pool)) {
return $forced_pool;
} elsif($forced_pool eq 'master') {
return $self->master;