[Bast-commits] r8277 - in
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI: . Replicated
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Sun Jan 10 11:04:52 GMT 2010
Author: caelum
Date: 2010-01-10 11:04:52 +0000 (Sun, 10 Jan 2010)
New Revision: 8277
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod
Log:
fix connection details in ::DBI::Replicated docs
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod 2010-01-10 10:30:35 UTC (rev 8276)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod 2010-01-10 11:04:52 UTC (rev 8277)
@@ -89,26 +89,25 @@
you use (or upgrade to) the latest L<Catalyst::Model::DBIC::Schema>, which makes
this job even easier.
-First, you need to connect your L<DBIx::Class::Schema>. Let's assume you have
-such a schema called, "MyApp::Schema".
+First, you need to get a C<$schema> object and set the storage_type:
- use MyApp::Schema;
- my $schema = MyApp::Schema->connect($dsn, $user, $pass);
+ my $schema = MyApp::Schema->clone;
+ $schema->storage_type([
+ '::DBI::Replicated' => {
+ balancer_type => '::Random',
+ balancer_args => {
+ auto_validate_every => 5,
+ master_read_weight => 1
+ },
+ pool_args => {
+ maximum_lag =>2,
+ },
+ }
+ ]);
-Next, you need to set the storage_type.
+Then, you need to connect your L<DBIx::Class::Schema>.
- $schema->storage_type(
- ::DBI::Replicated' => {
- balancer_type => '::Random',
- balancer_args => {
- auto_validate_every => 5,
- master_read_weight => 1
- },
- pool_args => {
- maximum_lag =>2,
- },
- }
- );
+ $schema->connection($dsn, $user, $pass);
Let's break down the settings. The method L<DBIx::Class::Schema/storage_type>
takes one mandatory parameter, a scalar value, and an option second value which
@@ -160,11 +159,11 @@
After you've configured the replicated storage, you need to add the connection
information for the replicants:
- $schema->storage->connect_replicants(
- [$dsn1, $user, $pass, \%opts],
- [$dsn2, $user, $pass, \%opts],
- [$dsn3, $user, $pass, \%opts],
- );
+ $schema->storage->connect_replicants(
+ [$dsn1, $user, $pass, \%opts],
+ [$dsn2, $user, $pass, \%opts],
+ [$dsn3, $user, $pass, \%opts],
+ );
These replicants should be configured as slaves to the master using the
instructions for MySQL native replication, or if you are just learning, you
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated.pm 2010-01-10 10:30:35 UTC (rev 8276)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Replicated.pm 2010-01-10 11:04:52 UTC (rev 8277)
@@ -50,7 +50,9 @@
also define your arguments, such as which balancer you want and any arguments
that the Pool object should get.
+ my $schema = Schema::Class->clone;
$schema->storage_type( ['::DBI::Replicated', {balancer=>'::Random'}] );
+ $schema->connection(...);
Next, you need to add in the Replicants. Basically this is an array of
arrayrefs, where each arrayref is database connect information. Think of these
More information about the Bast-commits
mailing list