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