documented methods for detecting replicant reliability, created stub methods
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Replicated / Replicant.pm
CommitLineData
26ab719a 1package DBIx::Class::Storage::DBI::Replicated::Replicant;
2
3use Moose;
4extends 'DBIx::Class::Storage::DBI', 'Moose::Object';
5
6=head1 NAME
7
8DBIx::Class::Storage::DBI::Replicated::Replicant; A replicated DBI Storage
9
10=head1 SYNOPSIS
11
12This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>. You
13shouldn't need to create instances of this class.
14
15=head1 DESCRIPTION
16
17Replicants are DBI Storages that follow a master DBI Storage. Typically this
18is accomplished via an external replication system. Please see the documents
19for L<DBIx::Class::Storage::DBI::Replicated> for more details.
20
21This class exists to define methods of a DBI Storage that only make sense when
22it's a classic 'slave' in a pool of slave databases which replicate from a
23given master database.
24
25=head1 ATTRIBUTES
26
27This class defines the following attributes.
28
50336325 29=head2 active
30
31This is a boolean which allows you to programmatically activate or deactivate a
32replicant from the pool. This way to you do stuff like disallow a replicant
33when it get's too far behind the master, if it stops replicating, etc.
34
9c748388 35This attribute DOES NOT reflect a replicant's internal status, i.e. if it is
36properly replicating from a master and has not fallen too many seconds behind a
37reliability threshold. For that, use L</is_replicating> and L</lag_behind_master>.
38Since the implementation of those functions database specific (and not all DBIC
39supported DB's support replication) you should refer your database specific
40storage driver for more information.
41
50336325 42=cut
43
44has 'active' => (
45 is=>'rw',
46 isa=>'Bool',
47 lazy=>1,
48 required=>1,
49 default=>1,
50);
51
26ab719a 52=head1 METHODS
53
54This class defines the following methods.
55
50336325 56=head2 after: _query_start
57
58advice iof the _query_start method to add more debuggin
59
60=cut
61
62around '_query_start' => sub {
63 my ($method, $self, $sql, @bind) = @_;
64 my $dsn = $self->connect_info->[0];
65 $self->$method("DSN: $dsn SQL: $sql", @bind);
66};
67
9c748388 68=head2 is_replicating
69
70A boolean that reports if a particular L<DBIx::Class::Storage::DBI> is set to
71replicate from a master database. Default is false, which is the result
72returned by databases that don't support replication.
73
74=cut
75
76sub is_replicating {
77 my $self = shift @_;
78}
79
80=head2 lag_behind_master
81
82Returns a number that represents a certain amount of lag behind a master db
83when a given storage is replicating. The number is database dependent, but
84starts at zero, which is the default, and increases with the amount of lag.
85
86=cut
87
88sub lag_behind_master {
89 my $self = shift @_;
90}
50336325 91
26ab719a 92=head1 AUTHOR
93
94John Napiorkowski <john.napiorkowski@takkle.com>
95
96=head1 LICENSE
97
98You may distribute this code under the same terms as Perl itself.
99
50336325 100=cut
101
1021;