Skip to content

Commit

Permalink
ElasticBackend now can be configured passing a list of 'hosts' or a l…
Browse files Browse the repository at this point in the history
…ist of 'connection_urls'.
  • Loading branch information
Marc Tudurí committed May 2, 2016
1 parent bdc1592 commit 374cbfd
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions kaneda/backends/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ class ElasticsearchBackend(BaseBackend):
"""
Elasticsearch backend.
:param index_name: name of the Elasticsearch index used to store metrics data. Default name format will be app_name-YYYY.MM.DD.
:param index_name: name of the Elasticsearch index used to store metrics data. Default name format will be \
index_name-YYYY.MM.DD.
:param app_name: name of the app/project where metrics are used.
:param client: client instance of Elasticsearch class.
:param connection_url: Elasticsearch connection url (https://user:secret@localhost:9200).
:param host: server host.
:param connection_url: Elasticsearch connection url (https://user:secret@localhost:9200). \
It can be used passing a single connection_url (a string) or passing multiple connection_urls (a list).
:param host: server host. It can be used passing a single host (a string) or passing multiple hosts (a list).
:param port: server port.
:param username: http auth username.
:param password: http auth password.
Expand All @@ -38,9 +40,13 @@ def __init__(self, index_name, app_name, client=None, connection_url=None, host=
raise ImproperlyConfigured('"client" parameter is not an instance of Elasticsearch client')
self.client = client
elif connection_url:
self.client = Elasticsearch([connection_url], timeout=timeout)
if not isinstance(connection_url, list):
connection_url = [connection_url]
self.client = Elasticsearch(connection_url, timeout=timeout)
else:
self.client = Elasticsearch([host], port=port, http_auth=(username, password), timeout=timeout)
if not isinstance(host, list):
host = [host]
self.client = Elasticsearch(host, port=port, http_auth=(username, password), timeout=timeout)
self.index_name = index_name
self.app_name = app_name

Expand Down

0 comments on commit 374cbfd

Please sign in to comment.