[dancer-users] Can I write own config in config.yml?

David Precious davidp at preshweb.co.uk
Mon Dec 10 15:00:48 GMT 2012

On Mon, 10 Dec 2012 22:45:39 +0800
chenlin rao <rao.chenlin at gmail.com> wrote:

> Then `get http://localhost:3000/a/config` show that servers: "
>" but `get http://localhost:3000/b/config` show that
> servers: "" which is the default setting of
> ElasticSearch module.

Ah - it's a bug in the ElasticSearch module - it modifies the params
hashref it gets passed (as it gets a reference, it's modifying what you
gave it).

In ElasticSearch->new, it passes the params hashref to
ElasticSearch::Transport->new, which includes the following:

    my $servers = delete $params->{servers}
        || '' . $transport_class->default_port;
    for (qw(timeout max_requests no_refresh deflate
    max_content_length)) { next unless exists $params->{$_};
        $self->$_( delete $params->{$_} );

Until this problem in ES is fixed, you'll want to take a copy/clone of
the config settings before giving them to ElasticSearch.

A simple way would be e.g.:

    my $elsearch = ElasticSearch->new( 
	{ %{ config->{ElasticSearch} } }

David Precious ("bigpresh") <davidp at preshweb.co.uk>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github

More information about the dancer-users mailing list