X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FReplicated%2FIntroduction.pod;h=19d3ccf8e6d62f4b8a865f75ec1cb16ec863290d;hp=c48f2a1bd3ea6bc558a391ebccfe5920374336b0;hb=ce854fd32662c78921b754a9e6f4815b1c2210ec;hpb=4225194590a09e29451ba825c34483f98c1a0c03 diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod b/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod index c48f2a1..19d3ccf 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod @@ -89,26 +89,25 @@ may wish to do this. Again, if you are using L, I strongly recommend you use (or upgrade to) the latest L, which makes this job even easier. -First, you need to connect your L. Let's assume you have -such a schema called, "MyApp::Schema". - - use MyApp::Schema; - my $schema = MyApp::Schema->connect($dsn, $user, $pass); - -Next, you need to set the storage_type. - - $schema->storage_type( - ::DBI::Replicated' => { - balancer_type => '::Random', - balancer_args => { - auto_validate_every => 5, - master_read_weight => 1 - }, - pool_args => { - maximum_lag =>2, - }, - } - ); +First, you need to get a C<$schema> object and set the storage_type: + + 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, + }, + } + ]); + +Then, you need to connect your L. + + $schema->connection($dsn, $user, $pass); Let's break down the settings. The method L takes one mandatory parameter, a scalar value, and an option second value which @@ -160,11 +159,11 @@ database. 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