Extra tests to ensure that the cond collapser will not mask SQLA deprecations
[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
48580715 36replicant from the pool. This way you can do stuff like disallow a replicant
37when it gets too far behind the master, if it stops replicating, etc.
50336325 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
5529838f 41reliability threshold. For that, use
42L<DBIx::Class::Storage::DBI::Replicated/is_replicating> and
43L<DBIx::Class::Storage::DBI::Replicated/lag_behind_master>.
9c748388 44Since the implementation of those functions database specific (and not all DBIC
48580715 45supported DBs support replication) you should refer your database-specific
9c748388 46storage driver for more information.
47
50336325 48=cut
49
50has 'active' => (
64cdad22 51 is=>'rw',
41916570 52 isa=>Bool,
64cdad22 53 lazy=>1,
54 required=>1,
55 default=>1,
50336325 56);
57
ede99b9f 58has dsn => (is => 'rw', isa => Str);
59has id => (is => 'rw', isa => Str);
0bd8e058 60
cea43436 61=head2 master
62
63Reference to the master Storage.
64
65=cut
66
67has master => (is => 'rw', isa => DBICStorageDBI, weak_ref => 1);
68
26ab719a 69=head1 METHODS
70
71This class defines the following methods.
72
edbf2778 73=head2 debugobj
74
75Override the debugobj method to redirect this method call back to the master.
76
77=cut
78
79sub debugobj {
cea43436 80 my $self = shift;
81
82 return $self->master->debugobj;
edbf2778 83}
84
e515254d 85=head1 ALSO SEE
86
ee356d00 87L<http://en.wikipedia.org/wiki/Replicant>,
88L<DBIx::Class::Storage::DBI::Replicated>
e515254d 89
a2bd3796 90=head1 FURTHER QUESTIONS?
26ab719a 91
a2bd3796 92Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
26ab719a 93
a2bd3796 94=head1 COPYRIGHT AND LICENSE
26ab719a 95
a2bd3796 96This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
97by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
98redistribute it and/or modify it under the same terms as the
99L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
26ab719a 100
50336325 101=cut
102
41916570 1031;