| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::RuledCluster::Strategy::Key; |
|
2
|
3
|
|
|
3
|
|
3338
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
112
|
|
|
3
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
119
|
|
|
4
|
3
|
|
|
3
|
|
1569
|
use parent 'Data::RuledCluster::Strategy'; |
|
|
3
|
|
|
|
|
1165
|
|
|
|
3
|
|
|
|
|
22
|
|
|
5
|
3
|
|
|
3
|
|
212
|
use Data::Util qw(is_number neat); |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
622
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub resolve { |
|
8
|
20
|
|
|
20
|
0
|
38
|
my ( $class, $resolver, $node_or_cluster, $args ) = @_; |
|
9
|
|
|
|
|
|
|
|
|
10
|
20
|
|
|
|
|
69
|
my @keys = $class->keys_from_args($args); |
|
11
|
20
|
|
|
|
|
39
|
my $key = shift @keys; |
|
12
|
|
|
|
|
|
|
|
|
13
|
20
|
50
|
|
|
|
123
|
unless ( is_number($key) ) { |
|
14
|
0
|
|
|
|
|
0
|
Carp::croak( |
|
15
|
|
|
|
|
|
|
sprintf('args has not key field or no number value (key: %s)', neat($key)) |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
20
|
|
|
|
|
87
|
my @nodes = $resolver->clusters($node_or_cluster); |
|
20
|
20
|
|
|
|
|
82
|
my $resolved_node = $nodes[ $key % scalar @nodes ]; |
|
21
|
|
|
|
|
|
|
|
|
22
|
20
|
|
|
|
|
79
|
return ($resolved_node, @keys); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
|
26
|
|
|
|
|
|
|
|