Skip to content

Commit

Permalink
Merge pull request #545 from Salaton/dynamic_es_scheme
Browse files Browse the repository at this point in the history
chore: make scheme configurable for elastic search connection
  • Loading branch information
rkorytkowski committed Jul 25, 2023
2 parents f909085 + aa3b698 commit c8ba1d2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,14 @@ def es_get(url, **kwargs):
for es_host in settings.ES_HOSTS.split(','):
try:
return requests.get(
f'http://{es_host}/{url}',
f'{settings.ES_SCHEME}://{es_host}/{url}',
**kwargs
)
except ConnectTimeout:
continue
else:
return requests.get(
f'http://{settings.ES_HOST}:{settings.ES_PORT}/{url}',
f'{settings.ES_SCHEME}://{settings.ES_HOST}:{settings.ES_PORT}/{url}',
**kwargs
)

Expand Down
1 change: 1 addition & 0 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
ES_HOST = os.environ.get('ES_HOST', 'es') # Deprecated. Use ES_HOSTS instead.
ES_PORT = os.environ.get('ES_PORT', '9200') # Deprecated. Use ES_HOSTS instead.
ES_HOSTS = os.environ.get('ES_HOSTS', None)
ES_SCHEME = os.environ.get('ES_SCHEME', 'http')
ELASTICSEARCH_DSL = {
'default': {
'hosts': ES_HOSTS.split(',') if ES_HOSTS else [ES_HOST + ':' + ES_PORT]
Expand Down
1 change: 1 addition & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
- DB_PORT=${DB_PORT-5432}
- DB_PASSWORD=${DB_PASSWORD-Postgres123}
- ES_HOSTS=${ES_HOSTS-es:9200}
- ES_SCHEME=${ES_SCHEME-http}
- ENVIRONMENT=production
- DEBUG=${DEBUG-FALSE}
- SECRET_KEY
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ services:
- DB_PORT=${DB_PORT-5432}
- DB_PASSWORD=${DB_PASSWORD-Postgres123}
- ES_HOSTS=${ES_HOSTS-es:9200}
- ES_SCHEME=${ES_SCHEME-http}
- ENVIRONMENT=${ENVIRONMENT-production}
- DEBUG=${DEBUG-FALSE}
- SECRET_KEY
Expand Down

0 comments on commit c8ba1d2

Please sign in to comment.