| Class-DBI-Replicated documentation | Contained in the Class-DBI-Replicated distribution. |
Class::DBI::Replicated::Pg::Slony1 - Pg replication using Slony1
package My::DBI; use base 'Class::DBI::Replicated::Pg::Slony1'; My::DBI->replication(...);
Additional options for replication.
slony1_schemaslony1_originreplication_argsreplication_setupSee Class::DBI::Replicated. Allow and set up slony1 options.
repl_get_masterrepl_get_slaverepl_compareHans Dieter Pearcey, <hdp@cpan.org>
Please report any bugs or feature requests to
bug-class-dbi-replicated-pg-slony1@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.
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.
| Class-DBI-Replicated documentation | Contained in the Class-DBI-Replicated distribution. |
package Class::DBI::Replicated::Pg::Slony1; use warnings; use strict; use base qw(Class::DBI::Pg Class::DBI::Replicated); use Params::Validate qw(:types);
sub replication_args { return ( slony1_schema => { type => SCALAR }, slony1_origin => { type => SCALAR }, ); } sub replication_setup { my ($class, $arg) = @_; $class->mk_class_accessors( '__slony1_schema', '__slony1_origin', '__slony1_slave_node' ); $class->__slony1_schema($arg->{slony1_schema}); $class->__slony1_origin($arg->{slony1_origin}); my %origin; my @slaves = @{ $arg->{slaves} }; while (my ($name, $slave_arg) = splice @slaves, 0, 2) { $origin{"Slave_$name"} = $slave_arg->{node}; } $class->__slony1_slave_node(\%origin); } # add 1 because of how slony1 works; that is, we care about # the next event generated, not the last one __PACKAGE__->set_sql(master_status => <<'', 'Master_Repl'); SELECT st_last_event + 1 FROM %s.sl_status WHERE st_origin = ? LIMIT 1 __PACKAGE__->set_sql(slave_status => <<'', 'Master_Repl'); SELECT st_last_received FROM %s.sl_status WHERE st_received = ? LIMIT 1
sub repl_get_master { my ($class) = @_; $class->repl_pos( $class->sql_master_status( $class->__slony1_schema )->select_val( 1 ), ); }
sub repl_get_slave { my ($class) = @_; my $sth = $class->sql_slave_status( $class->__slony1_schema ); return $sth->select_val( $class->__slony1_slave_node->{$class->__slave_db} ); }
sub repl_compare { my ($class, $test, $ref) = @_; return $test >= $ref; }
1; # End of Class::DBI::Replicated::Pg::Slony1