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