1 package DBIx::Class::Storage::DBI::Replicated::Balancer;
4 use List::Util qw(shuffle);
8 DBIx::Class::Storage::DBI::Replicated::Balancer; A Software Load Balancer
12 This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>. You
13 shouldn't need to create instances of this class.
17 Given a pool (L<DBIx::Class::Storage::DBI::Replicated::Pool>) of replicated
18 database's (L<DBIx::Class::Storage::DBI::Replicated::Replicant>), defines a
19 method by which query load can be spread out across each replicant in the pool.
23 This class defines the following attributes.
27 This class defines the following methods.
29 =head2 next_storage ($pool)
31 Given a pool object, return the next replicant that will serve queries. The
32 default behavior is to randomize but you can write your own subclasses of
33 L<DBIx::Class::Storage::DBI::Replicated::Balancer> to support other balance
42 return (shuffle($pool->all_replicants))[0];
48 John Napiorkowski <john.napiorkowski@takkle.com>
52 You may distribute this code under the same terms as Perl itself.