Skip to content

Commit

Permalink
fix sniff
Browse files Browse the repository at this point in the history
  • Loading branch information
zcqian committed Oct 23, 2021
1 parent acf1190 commit 316cc4e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions biothings/web/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,19 @@ 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
)

if settings.get('sniff', None) is None:
settings.update(
sniff=True,
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.get('sniff', False):
_sniff_defaults = {
'sniff_on_start': True,
'sniff_on_connection_fail': True,
'sniffer_timeout': 60,
}
for k, v in _sniff_defaults.items():
settings[k] = settings.get('k', v)

if async_:
from elasticsearch import AsyncElasticsearch
Expand Down

0 comments on commit 316cc4e

Please sign in to comment.