line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::RuledCluster::Strategy::List; |
2
|
2
|
|
|
2
|
|
1277
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
51
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
730
|
use parent 'Data::RuledCluster::Strategy'; |
|
2
|
|
|
|
|
532
|
|
|
2
|
|
|
|
|
9
|
|
5
|
2
|
|
|
2
|
|
74
|
use Carp (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
34
|
|
6
|
2
|
|
|
2
|
|
9
|
use Data::Util qw(is_hash_ref is_array_ref); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
563
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub resolve { |
9
|
51
|
|
|
51
|
0
|
100
|
my ($class, $resolver, $node_or_cluster, $args) = @_; |
10
|
|
|
|
|
|
|
|
11
|
51
|
|
|
|
|
116
|
my @keys = $class->keys_from_args($args); |
12
|
51
|
|
|
|
|
83
|
my $key = shift @keys; |
13
|
|
|
|
|
|
|
|
14
|
51
|
100
|
|
|
|
112
|
if ( not exists $args->{list_map} ) { |
15
|
39
|
50
|
33
|
|
|
154
|
if ( not exists $args->{strategy_config} && is_hash_ref( $args->{strategy_config} ) ) { |
16
|
0
|
|
|
|
|
0
|
Carp::croak('strategy_config is not exists or is not hash ref'); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
39
|
|
|
|
|
64
|
my $strategy_config = $args->{strategy_config}; |
20
|
|
|
|
|
|
|
$args->{list_map} = +{ |
21
|
|
|
|
|
|
|
map { |
22
|
54
|
|
|
|
|
71
|
my $node = $_; |
23
|
54
|
|
|
|
|
62
|
map { $_ => $node } @{ $args->{strategy_config}->{$node} } |
|
90
|
|
|
|
|
232
|
|
|
54
|
|
|
|
|
83
|
|
24
|
|
|
|
|
|
|
} |
25
|
39
|
|
|
|
|
86
|
grep { length $_ > 0 } |
|
81
|
|
|
|
|
172
|
|
26
|
|
|
|
|
|
|
keys %$strategy_config |
27
|
|
|
|
|
|
|
}; |
28
|
39
|
100
|
|
|
|
96
|
if ( exists $strategy_config->{""} ) { |
29
|
27
|
|
33
|
|
|
118
|
$args->{list_fallback} ||= $strategy_config->{""}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
51
|
50
|
66
|
|
|
129
|
if ( !exists $args->{list_fallback} && !exists $args->{list_map}->{$key} ) { |
34
|
0
|
|
|
|
|
0
|
Carp::croak(sprintf("Not exists fallback, The key '%d' has not route", $key )); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
51
|
|
|
|
|
67
|
my $resolved_node; |
38
|
51
|
100
|
|
|
|
118
|
if ( exists $args->{list_map}->{$key} ) { |
39
|
28
|
|
|
|
|
39
|
$resolved_node = $args->{list_map}{$key}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
23
|
|
|
|
|
37
|
$resolved_node = $args->{list_fallback}; |
43
|
23
|
|
|
|
|
40
|
unshift( @keys, $key ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
51
|
|
|
|
|
184
|
return ( $resolved_node, @keys ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|