Replicated - fixup types and namespace::clean
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Replicated / Replicant.pm
CommitLineData
26ab719a 1package DBIx::Class::Storage::DBI::Replicated::Replicant;
2
de5dc9ef 3use Moose::Role;
edbf2778 4requires qw/_query_start/;
41916570 5use MooseX::Types::Moose qw/Bool/;
6
7use namespace::clean -except => 'meta';
26ab719a 8
9=head1 NAME
10
21fc4719 11DBIx::Class::Storage::DBI::Replicated::Replicant - A replicated DBI Storage Role
26ab719a 12
13=head1 SYNOPSIS
14
de5dc9ef 15This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>.
26ab719a 16
17=head1 DESCRIPTION
18
19Replicants are DBI Storages that follow a master DBI Storage. Typically this
20is accomplished via an external replication system. Please see the documents
21for L<DBIx::Class::Storage::DBI::Replicated> for more details.
22
23This class exists to define methods of a DBI Storage that only make sense when
24it's a classic 'slave' in a pool of slave databases which replicate from a
25given master database.
26
27=head1 ATTRIBUTES
28
29This class defines the following attributes.
30
50336325 31=head2 active
32
33This is a boolean which allows you to programmatically activate or deactivate a
34replicant from the pool. This way to you do stuff like disallow a replicant
35when it get's too far behind the master, if it stops replicating, etc.
36
9c748388 37This attribute DOES NOT reflect a replicant's internal status, i.e. if it is
38properly replicating from a master and has not fallen too many seconds behind a
39reliability threshold. For that, use L</is_replicating> and L</lag_behind_master>.
40Since the implementation of those functions database specific (and not all DBIC
41supported DB's support replication) you should refer your database specific
42storage driver for more information.
43
50336325 44=cut
45
46has 'active' => (
64cdad22 47 is=>'rw',
41916570 48 isa=>Bool,
64cdad22 49 lazy=>1,
50 required=>1,
51 default=>1,
50336325 52);
53
26ab719a 54=head1 METHODS
55
56This class defines the following methods.
57
f15afa13 58=head2 around: _query_start
50336325 59
60advice iof the _query_start method to add more debuggin
61
62=cut
63
64around '_query_start' => sub {
64cdad22 65 my ($method, $self, $sql, @bind) = @_;
16df8aa9 66 my $dsn = $self->_dbi_connect_info->[0];
64cdad22 67 $self->$method("DSN: $dsn SQL: $sql", @bind);
50336325 68};
69
edbf2778 70=head2 debugobj
71
72Override the debugobj method to redirect this method call back to the master.
73
74=cut
75
76sub debugobj {
77 return shift->schema->storage->debugobj;
78}
79
e515254d 80=head1 ALSO SEE
81
82L<<a href="http://en.wikipedia.org/wiki/Replicant">http://en.wikipedia.org/wiki/Replicant</a>>
83
26ab719a 84=head1 AUTHOR
85
86John Napiorkowski <john.napiorkowski@takkle.com>
87
88=head1 LICENSE
89
90You may distribute this code under the same terms as Perl itself.
91
50336325 92=cut
93
41916570 941;