File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,23 @@ use Search::Elasticsearch;
10
10
use MetaCPAN::Ingest qw< config handle_error > ;
11
11
12
12
sub new ( $class , %args ) {
13
+ my $mode = $args {mode } // " local" ;
13
14
my $node = $args {node };
14
15
my $index = $args {index } // " cpan" ;
15
16
16
17
my $config = config;
17
- $node ||= $config -> {es_node };
18
- $node or die " Cannot create an ES instance without a node\n " ;
18
+ my $config_node =
19
+ $node ? $node :
20
+ $mode eq ' local' ? $config -> {es_node } :
21
+ $mode eq ' test' ? $config -> {es_test_node } :
22
+ $mode eq ' prod' ? $config -> {es_production_node } :
23
+ undef ;
24
+ $config_node or die " Cannot create an ES instance without a node\n " ;
19
25
20
26
return bless {
21
27
es => Search::Elasticsearch-> new(
22
28
client => ' 2_0::Direct' ,
23
- nodes => [$node ],
29
+ nodes => [$config_node ],
24
30
),
25
31
index => $index ,
26
32
( $args {type } ? ( type => $args {type } ) : () ),
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ log4perl_file log4perl.conf
4
4
5
5
es_node "elasticsearch:9200"
6
6
7
- # Dev: for testing -
7
+ # for local data tests
8
+ es_test_node "elasticsearch_test:9200"
9
+
8
10
# to enable *reading* from profuction (check it's used in the code):
9
- es_test_node "https://fastapi.metacpan.org/v1"
11
+ es_production_node "https://fastapi.metacpan.org/v1"
You can’t perform that action at this time.
0 commit comments