1 package DBIx::Class::Storage::DBI::Replicated::Balancer::Random;
3 use List::Util qw(shuffle);
5 with 'DBIx::Class::Storage::DBI::Replicated::Balancer';
9 DBIx::Class::Storage::DBI::Replicated::Balancer::Random; A 'random' Balancer
13 This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>. You
14 shouldn't need to create instances of this class.
18 Given a pool (L<DBIx::Class::Storage::DBI::Replicated::Pool>) of replicated
19 database's (L<DBIx::Class::Storage::DBI::Replicated::Replicant>), defines a
20 method by which query load can be spread out across each replicant in the pool.
22 This Balancer uses L<List::Util> keyword 'shuffle' to randomly pick an active
23 replicant from the associated pool. This may or may not be random enough for
28 This class defines the following attributes.
32 This class defines the following methods.
36 Returns an active replicant at random. Please note that due to the nature of
37 the word 'random' this means it's possible for a particular active replicant to
38 be requested several times in a row.
43 return (shuffle(shift->pool->active_replicants))[0];
48 John Napiorkowski <john.napiorkowski@takkle.com>
52 You may distribute this code under the same terms as Perl itself.