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