Skip to content

Commit

Permalink
fix ES default sniff config updates
Browse files Browse the repository at this point in the history
  • Loading branch information
zcqian committed Oct 23, 2021
1 parent 8defa1e commit f814b96
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions biothings/web/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,20 @@ def get_es_client(hosts=None, async_=False, **settings):
http_auth=awsauth, use_ssl=True, verify_certs=True,
connection_class=_AsyncConn if async_ else _Conn
)
elif settings.pop('sniff', None):
settings.update(
sniff_on_start=True,
sniff_on_connection_fail=True,
sniffer_timeout=60
)
# Sniff is only possible if not using the managed cluster
# TODO: maybe we won't ever use it
# by default we don't do sniffing
# if sniff is set, then populate with reasonable defaults unless
# explicitly set
elif settings.pop('sniff', False):
_sniff_defaults = {
'sniff_on_start': True,
'sniff_on_connection_fail': True,
'sniffer_timeout': 60,
}
for setting_name, setting_default in _sniff_defaults.items():
settings.setdefault(setting_name, setting_default)

if async_:
from elasticsearch import AsyncElasticsearch
client = AsyncElasticsearch
Expand Down

0 comments on commit f814b96

Please sign in to comment.