line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Plugin::Apache::Solr; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
868420
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
76
|
|
6
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
68
|
|
7
|
3
|
|
|
3
|
|
6617
|
use utf8; |
|
3
|
|
|
|
|
29
|
|
|
3
|
|
|
|
|
18
|
|
8
|
3
|
|
|
3
|
|
1849
|
use Dancer::Plugin; |
|
3
|
|
|
|
|
3656
|
|
|
3
|
|
|
|
|
226
|
|
9
|
3
|
|
|
3
|
|
1969
|
use Apache::Solr; |
|
3
|
|
|
|
|
352077
|
|
|
3
|
|
|
|
|
900
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $servers = {}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub solr { |
14
|
5
|
|
|
5
|
|
4991
|
my ($self, $name) = plugin_args(@_); |
15
|
5
|
|
|
|
|
31
|
my $cfg = plugin_setting; |
16
|
|
|
|
|
|
|
|
17
|
5
|
100
|
|
|
|
93
|
if (not defined $name) { |
18
|
4
|
100
|
|
|
|
18
|
if (keys %$cfg == 1) { |
|
|
50
|
|
|
|
|
|
19
|
1
|
|
|
|
|
3
|
($name) = keys %$cfg; |
20
|
|
|
|
|
|
|
} elsif (keys %$cfg) { |
21
|
3
|
|
|
|
|
8
|
$name = "default"; |
22
|
|
|
|
|
|
|
} else { |
23
|
0
|
|
|
|
|
0
|
die "No Solr servers are configured"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
5
|
50
|
|
|
|
16
|
return $servers->{$name} if $servers->{$name}; |
28
|
|
|
|
|
|
|
|
29
|
5
|
100
|
|
|
|
41
|
my $options = $cfg->{$name} or die "The server $name is not configured"; |
30
|
|
|
|
|
|
|
|
31
|
3
|
50
|
|
|
|
15
|
if ( my $alias = $options->{alias} ) { |
32
|
0
|
0
|
|
|
|
0
|
$options = $cfg->{$alias} |
33
|
|
|
|
|
|
|
or die "The server alias $alias does not exist in the config"; |
34
|
0
|
0
|
|
|
|
0
|
return $servers->{$alias} if $servers->{$alias}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $server_info = |
38
|
|
|
|
|
|
|
$options->{server_info} |
39
|
|
|
|
|
|
|
// |
40
|
|
|
|
|
|
|
{ |
41
|
3
|
|
50
|
|
|
22
|
map { $_, $options->{$_} } qw( |
|
15
|
|
|
|
|
51
|
|
42
|
|
|
|
|
|
|
autocommit |
43
|
|
|
|
|
|
|
core |
44
|
|
|
|
|
|
|
format |
45
|
|
|
|
|
|
|
server |
46
|
|
|
|
|
|
|
server_version |
47
|
|
|
|
|
|
|
) |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
; |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
9
|
my $server; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
37
|
$server = Apache::Solr->new(%$server_info); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return $servers->{$name} = $server; |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
register solr => \&solr; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
register_plugin for_versions => [ 1, 2 ]; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# ABSTRACT: Apache::Solr interface for Dancer applications |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |