[Catalyst-commits] r10056 - in trunk/Catalyst-Model-DBIC-Schema: .
lib/Catalyst/Model/DBIC lib/Catalyst/Model/DBIC/Schema
lib/Catalyst/Model/DBIC/Schema/Role
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Sat May 9 09:59:47 GMT 2009
Author: caelum
Date: 2009-05-09 09:59:46 +0000 (Sat, 09 May 2009)
New Revision: 10056
Modified:
trunk/Catalyst-Model-DBIC-Schema/Makefile.PL
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Replicated.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm
Log:
C::M::DBIC::Schema - finish up Role::Replicated
Modified: trunk/Catalyst-Model-DBIC-Schema/Makefile.PL
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Makefile.PL 2009-05-08 23:11:52 UTC (rev 10055)
+++ trunk/Catalyst-Model-DBIC-Schema/Makefile.PL 2009-05-09 09:59:46 UTC (rev 10056)
@@ -3,8 +3,9 @@
name 'Catalyst-Model-DBIC-Schema';
all_from 'lib/Catalyst/Model/DBIC/Schema.pm';
-requires 'DBIx::Class' => '0.08100';
+requires 'DBIx::Class' => '0.08104';
requires 'Catalyst::Runtime' => '5.80002';
+requires 'Moose';
requires 'Moose::Autobox';
requires 'MooseX::ClassAttribute';
requires 'MooseX::Types';
@@ -24,6 +25,9 @@
feature 'Caching support',
'DBIx::Class::Cursor::Cached' => 0;
+feature 'Replication support',
+ 'MooseX::AttributeHelpers' => 0;
+
if(-e 'MANIFEST.SKIP') {
system("pod2text lib/Catalyst/Model/DBIC/Schema.pm > README");
}
Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm 2009-05-08 23:11:52 UTC (rev 10055)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm 2009-05-09 09:59:46 UTC (rev 10056)
@@ -1,7 +1,7 @@
package Catalyst::Model::DBIC::Schema::Role::Caching;
use Moose::Role;
-use Carp::Clan '^Catalyst::Model::DBIC::Schema::';
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
use namespace::clean -except => 'meta';
Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Replicated.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Replicated.pm 2009-05-08 23:11:52 UTC (rev 10055)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Replicated.pm 2009-05-09 09:59:46 UTC (rev 10056)
@@ -2,7 +2,7 @@
use Moose::Role;
use Moose::Autobox;
-use Carp::Clan '^Catalyst::Model::DBIC::Schema::';
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
use Catalyst::Model::DBIC::Schema::Types 'ConnectInfos';
@@ -23,17 +23,26 @@
['dbi:mysql:slave1', 'user', 'pass'],
['dbi:mysql:slave2', 'user', 'pass'],
['dbi:mysql:slave3', 'user', 'pass'],
- ]
+ ],
+ balancer_args => {
+ master_read_weight => 0.3
+ }
});
=head1 DESCRIPTION
-B<DOES NOT WORK YET> -- requires some DBIC changes
-
Sets your storage_type to L<DBIx::Class::Storage::DBI::Replicated> and connects
replicants provided in config. See that module for supported resultset
attributes.
+The default L<DBIx::Class::Storage::DBI::Replicated/balancer_type> is
+C<::Random>.
+
+Sets the
+L<DBIx::Class::Storage::DBI::Replicated::Balancer::Random/master_read_weight> to
+C<1> by default, meaning that you have the same chance of reading from master as
+you do from replicants. Set to C<0> to turn off reads from master.
+
=head1 CONFIG PARAMETERS
=head2 replicants
@@ -61,13 +70,19 @@
$self->storage_type('::DBI::Replicated');
}
- $self->connect_info->{balancer_type} ||= '::Random';
+ $self->connect_info->{balancer_type} ||= '::Random'
+ unless $self->connect_info->{balancer_type};
+
+ unless ($self->connect_info->{balancer_args} &&
+ exists $self->connect_info->{balancer_args}{master_read_weight}) {
+ $self->connect_info->{balancer_args}{master_read_weight} = 1;
+ }
};
after finalize => sub {
my $self = shift;
- $self->storage->connect_replicants(map [ $_ ], $self->replicants->flatten);
+ $self->storage->connect_replicants($self->replicants->flatten);
};
=head1 SEE ALSO
Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm 2009-05-08 23:11:52 UTC (rev 10055)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm 2009-05-09 09:59:46 UTC (rev 10056)
@@ -3,7 +3,7 @@
use MooseX::Types
-declare => [qw/ConnectInfo ConnectInfos Replicants SchemaClass/];
-use Carp::Clan '^Catalyst::Model::DBIC::Schema::';
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
use MooseX::Types::Moose qw/ArrayRef HashRef Str ClassName/;
use Scalar::Util 'reftype';
use List::MoreUtils 'all';
Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm 2009-05-08 23:11:52 UTC (rev 10055)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm 2009-05-09 09:59:46 UTC (rev 10056)
@@ -7,7 +7,7 @@
our $VERSION = '0.24';
-use Carp::Clan '^Catalyst::Model::DBIC::Schema::';
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
use Data::Dumper;
use DBIx::Class ();
use Scalar::Util 'reftype';
More information about the Catalyst-commits
mailing list