Last active
October 12, 2021 03:33
-
-
Save dmontagu/f7bb7db40e63f5bc6304ceba54604c89 to your computer and use it in GitHub Desktop.
Elasticsearch config files for use with FastAPI generated project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.3' | |
services: | |
db: | |
volumes: | |
- app-db-data:/var/lib/postgresql/data/pgdata | |
deploy: | |
placement: | |
constraints: | |
- node.labels.${STACK_NAME}.app-db-data == true | |
es01: | |
volumes: | |
- app-es-data-01:/usr/share/elasticsearch/data | |
deploy: | |
placement: | |
constraints: | |
- node.labels.${STACK_NAME}.app-es-data-01 == true | |
es02: | |
volumes: | |
- app-es-data-02:/usr/share/elasticsearch/data | |
deploy: | |
placement: | |
constraints: | |
- node.labels.${STACK_NAME}.app-es-data-02 == true | |
proxy: | |
deploy: | |
placement: | |
constraints: | |
- node.role == manager | |
volumes: | |
app-db-data: | |
app-es-data-01: | |
driver: local | |
app-es-data-02: | |
driver: local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from elasticsearch import Elasticsearch | |
from elasticsearch_async import AsyncElasticsearch | |
from app.core import config | |
ES_HOST = f"{config.elasticsearch_server}:{config.elasticsearch_port}" | |
def get_elasticsearch() -> Elasticsearch: | |
return Elasticsearch(hosts=[ES_HOST]) | |
def get_async_elasticsearch(loop=None) -> AsyncElasticsearch: | |
return AsyncElasticsearch(hosts=[ES_HOST], loop=loop) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Used by elasticsearch service | |
cluster.name=docker-cluster | |
bootstrap.memory_lock=true | |
"ES_JAVA_OPTS=-Xms512m -Xmx512m" | |
# Used by backend service | |
ELASTICSEARCH_SERVER=es01 | |
ELASTICSEARCH_PORT=9200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment