« DBIx/Class/Storage/DBI/Replicated/Pool.pm
↑ Summary
DBIx/Class/Storage/DBI/Replicated/WithDSN.pm »
| 1 | package DBIx::Class::Storage::DBI::Replicated::Replicant; | ||
| 2 | |||
| 3 | 0 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 4 | requires qw/_query_start/; | ||
| 5 | with 'DBIx::Class::Storage::DBI::Replicated::WithDSN'; | ||
| 6 | use MooseX::Types::Moose qw/Bool Str/; | ||
| 7 | use DBIx::Class::Storage::DBI::Replicated::Types 'DBICStorageDBI'; | ||
| 8 | |||
| 9 | use namespace::clean -except => 'meta'; | ||
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | DBIx::Class::Storage::DBI::Replicated::Replicant - A replicated DBI Storage Role | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>. | ||
| 18 | |||
| 19 | =head1 DESCRIPTION | ||
| 20 | |||
| 21 | Replicants are DBI Storages that follow a master DBI Storage. Typically this | ||
| 22 | is accomplished via an external replication system. Please see the documents | ||
| 23 | for L<DBIx::Class::Storage::DBI::Replicated> for more details. | ||
| 24 | |||
| 25 | This class exists to define methods of a DBI Storage that only make sense when | ||
| 26 | it's a classic 'slave' in a pool of slave databases which replicate from a | ||
| 27 | given master database. | ||
| 28 | |||
| 29 | =head1 ATTRIBUTES | ||
| 30 | |||
| 31 | This class defines the following attributes. | ||
| 32 | |||
| 33 | =head2 active | ||
| 34 | |||
| 35 | This is a boolean which allows you to programmatically activate or deactivate a | ||
| 36 | replicant from the pool. This way you can do stuff like disallow a replicant | ||
| 37 | when it gets too far behind the master, if it stops replicating, etc. | ||
| 38 | |||
| 39 | This attribute DOES NOT reflect a replicant's internal status, i.e. if it is | ||
| 40 | properly replicating from a master and has not fallen too many seconds behind a | ||
| 41 | reliability threshold. For that, use | ||
| 42 | L<DBIx::Class::Storage::DBI::Replicated/is_replicating> and | ||
| 43 | L<DBIx::Class::Storage::DBI::Replicated/lag_behind_master>. | ||
| 44 | Since the implementation of those functions database specific (and not all DBIC | ||
| 45 | supported DBs support replication) you should refer your database-specific | ||
| 46 | storage driver for more information. | ||
| 47 | |||
| 48 | =cut | ||
| 49 | |||
| 50 | has 'active' => ( | ||
| 51 | is=>'rw', | ||
| 52 | isa=>Bool, | ||
| 53 | lazy=>1, | ||
| 54 | required=>1, | ||
| 55 | default=>1, | ||
| 56 | ); | ||
| 57 | |||
| 58 | has dsn => (is => 'rw', isa => Str); | ||
| 59 | has id => (is => 'rw', isa => Str); | ||
| 60 | |||
| 61 | =head2 master | ||
| 62 | |||
| 63 | Reference to the master Storage. | ||
| 64 | |||
| 65 | =cut | ||
| 66 | |||
| 67 | has master => (is => 'rw', isa => DBICStorageDBI, weak_ref => 1); | ||
| 68 | |||
| 69 | =head1 METHODS | ||
| 70 | |||
| 71 | This class defines the following methods. | ||
| 72 | |||
| 73 | =head2 debugobj | ||
| 74 | |||
| 75 | Override the debugobj method to redirect this method call back to the master. | ||
| 76 | |||
| 77 | =cut | ||
| 78 | |||
| 79 | sub debugobj { | ||
| 80 | my $self = shift; | ||
| 81 | |||
| 82 | return $self->master->debugobj; | ||
| 83 | } | ||
| 84 | |||
| 85 | =head1 ALSO SEE | ||
| 86 | |||
| 87 | L<http://en.wikipedia.org/wiki/Replicant>, | ||
| 88 | L<DBIx::Class::Storage::DBI::Replicated> | ||
| 89 | |||
| 90 | =head1 FURTHER QUESTIONS? | ||
| 91 | |||
| 92 | Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. | ||
| 93 | |||
| 94 | =head1 COPYRIGHT AND LICENSE | ||
| 95 | |||
| 96 | This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> | ||
| 97 | by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can | ||
| 98 | redistribute it and/or modify it under the same terms as the | ||
| 99 | L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. | ||
| 100 | |||
| 101 | =cut | ||
| 102 | |||
| 103 | 1; | ||