blob: 639d4722a50deb22ed64a35e857f72dfc310180f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package Net::Riak::Role::Hosts;
use Moose::Role;
use Net::Riak::Types qw(RiakHost);
has host => (
is => 'rw',
isa => RiakHost,
coerce => 1,
default => 'http://127.0.0.1:8098',
);
sub get_host {
my $self = shift;
my $choice;
my $rand = rand;
for (@{$self->host}) {
$choice = $_->{node};
($rand -= $_->{weight}) <= 0 and last;
}
$choice;
}
1;
|