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;
1010use MetaCPAN::Ingest qw< config handle_error > ;
1111
1212sub new ( $class , %args ) {
13+ my $mode = $args {mode } // " local" ;
1314 my $node = $args {node };
1415 my $index = $args {index } // " cpan" ;
1516
1617 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 " ;
1925
2026 return bless {
2127 es => Search::Elasticsearch-> new(
2228 client => ' 2_0::Direct' ,
23- nodes => [$node ],
29+ nodes => [$config_node ],
2430 ),
2531 index => $index ,
2632 ( $args {type } ? ( type => $args {type } ) : () ),
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ log4perl_file log4perl.conf
44
55es_node "elasticsearch:9200"
66
7- # Dev: for testing -
7+ # for local data tests
8+ es_test_node "elasticsearch_test:9200"
9+
810# 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