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