NAME

Class::DBI::Replicated - Replication from single master to multiple slaves

VERSION

Version 0.040

SYNOPSIS

package My::DBI;
use base qw(Class::DBI::Replicated::mysql);
# use base qw(Class::DBI::Replicated::Pg::Slony1);

My::DBI->replication(\%arg);

DESCRIPTION

Class::DBI::Replicated does some stuff, blah blah.

METHODS

replication

$class->replication(\%arg);

Analogous to connection. Takes a single hashref.

master

a single arrayref (as passed to connection)

slaves

an arrayref of arrayrefs, one per slave. NOTE: currently, using more than one slave does nothing.

user
password

If present, these specify the user and password to use for replication-specific queries (such as MySQL's SHOW MASTER STATUS).

replication_db

Returns the name of the current database in use (minus the leading db_).

db_Main

Return a master or slave DBH, as dictated by the current replication state.

db_Slave

Always returns a DBH for the most recently-used slave.

db_Master

Generated by Class::DBI.

db_Slave_Repl

Most recently-used slave's connection for replication.

Falls back to db_Slave if no user/password given

db_Master_Repl

Master's connection for replication.

Falls back to db_Master if no user/password given

switch_to_master

switch_to_slave

wait_for_slave

REPLICATION METHODS

That is, methods dealing specifically with replication positions.

repl_mark

Get current master position and save it

repl_pos

Class data accessor/mutator for current marked master position

repl_get_master

virtual (scalar)

repl_get_slave

virtual (scalar)

repl_check

if ($class->repl_check) { ...

repl_wait

unless ($class->repl_wait(\%arg)) {
  # not up to date
}

Possible arguments:

timeout

defaults to 30

slave

slave name, defaults to the first one

fatal

die instead of returning 0

return 0 for failure

repl_compare

my $later = $class->repl_compare($my_pos, $master_pos);

virtual (boolean)

return 1 if $my_pos is at least as new as $master_pos return 0 otherwise

TRIGGERS

before_create

before_update

before_delete

switch to using master

after_create

after_update

after_delete

mark master position

select

SUBCLASSING

mk_force_masters

mk_markers

replication_args

Extra Params::Validate specifications for replication.

replication_setup

Called automatically inside replication.

Gets a hashref of the arguments to replication.

AUTHOR

Hans Dieter Pearcey, <hdp@cpan.org>

BUGS

Please report any bugs or feature requests to bug-class-dbi-replicated@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-DBI-Replicated. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2005 Hans Dieter Pearcey, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.