File tree Expand file tree Collapse file tree 5 files changed +18
-12
lines changed Expand file tree Collapse file tree 5 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,10 @@ has snap_name => (
8282has host => (
8383 is => ' ro' ,
8484 isa => Str,
85- default =>
86- sub { MetaCPAN::Server::Config::config()-> {elasticsearch_servers } },
85+ default => sub {
86+ my $self = shift ;
87+ return $self -> es-> transport-> cxn_pool-> cxns-> [0]-> uri;
88+ },
8789 documentation => ' ES host, defaults to: http://localhost:9200' ,
8890);
8991
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ git: /usr/bin/git
44cpan : /CPAN
55secret : " the stone roses"
66level : info
7- elasticsearch_servers : http://elasticsearch:9200
7+ elasticsearch_servers :
8+ client : ' 2_0::Direct'
9+ nodes : http://elasticsearch:9200
810minion_dsn : " postgresql://metacpan:t00lchain@pghost:5432/minion_queue"
911port : 5000
1012
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ level: warn
44port : 5000
55source_base : var/t/tmp/source
66
7- elasticsearch_servers : http://elasticsearch_test:9200
7+ elasticsearch_servers :
8+ client : ' 2_0::Direct'
9+ nodes : http://elasticsearch_test:9200
810
911logger :
1012 class : Log::Log4perl::Appender::Screen
Original file line number Diff line number Diff line change @@ -40,8 +40,7 @@ sub app {
4040
4141sub model {
4242 my $c = MetaCPAN::Server::Config::config();
43- MetaCPAN::Model-> new(
44- es => { nodes => [ $c -> {elasticsearch_servers } ] } );
43+ MetaCPAN::Model-> new( es => $c -> {elasticsearch_servers } );
4544}
4645
47461;
Original file line number Diff line number Diff line change @@ -18,12 +18,14 @@ use MetaCPAN::Server ();
1818use MetaCPAN::Server::Config ();
1919use MetaCPAN::TestHelpers qw( fakecpan_dir ) ;
2020use MetaCPAN::Types::TypeTiny qw( HashRef Path ) ;
21+ use MooseX::Types::ElasticSearch qw( ES ) ;
2122use Search::Elasticsearch ();
2223use Test::More;
2324
2425has es_client => (
2526 is => ' ro' ,
26- does => ' Search::Elasticsearch::Role::Client' ,
27+ isa => ES,
28+ coerce => 1,
2729 lazy => 1,
2830 builder => ' _build_es_client' ,
2931);
@@ -64,14 +66,13 @@ sub _build_config {
6466sub _build_es_client {
6567 my $self = shift ;
6668
67- my $es = Search::Elasticsearch-> new(
68- nodes => MetaCPAN::Server::Config::config()-> {elasticsearch_servers },
69- ( $ENV {ES_TRACE } ? ( trace_to => [ ' File' , ' es.log' ] ) : () )
70- );
69+ my $es = ES-> coerce(
70+ MetaCPAN::Server::Config::config()-> {elasticsearch_servers }, );
7171
72- ok( $es , ' got ElasticSearch object' );
72+ ok( $es , ' got Search::Elasticsearch object' );
7373
7474 note( Test::More::explain( { ' Elasticsearch info' => $es -> info } ) );
75+
7576 return $es ;
7677}
7778
You can’t perform that action at this time.
0 commit comments