# Path: importer/importer/settings.py
# ELASTICSEARCH_ENDPOINTS = [
#     unprefix(
#         os.environ.get('ELASTICSEARCH_URL', 'elasticsearch:9200'),
#         'http://'
#     )
# ]
# 
# Path: importer/importer/utils/services.py
# def wait_for_all_services(endpoint_list, timeout):
#     for endpoint in endpoint_list:
#         wait_for_service(endpoint, timeout)


from elasticsearch import Elasticsearch
from .settings import ELASTICSEARCH_ENDPOINTS
from .utils.services import wait_for_all_services



def connect_to_elasticsearch():
    print("Connecting to Elasticsearch...")
    wait_for_all_services(ELASTICSEARCH_ENDPOINTS, timeout=10)

# Path: importer/importer/settings.py
# ELASTICSEARCH_ENDPOINTS = [
#     unprefix(
#         os.environ.get('ELASTICSEARCH_URL', 'elasticsearch:9200'),
#         'http://'
#     )
# ]
# 
# Path: importer/importer/utils/services.py
# def wait_for_all_services(endpoint_list, timeout):
#     for endpoint in endpoint_list:
#         wait_for_service(endpoint, timeout)


# Path: importer/importer/connections.py
from elasticsearch import Elasticsearch
from .settings import ELASTICSEARCH_ENDPOINTS
from .utils.services import wait_for_all_services




def connect_to_elasticsearch():
    print("Connecting to Elasticsearch...")
    wait_for_all_services(ELASTICSEARCH_ENDPOINTS, timeout=10)

    return Elasticsearch(ELASTICSEARCH_ENDPOINTS)