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