Ian Hosein

14 papers C 1Journal 7Unranked 5
YearRankTypeTitle / Venue / Authors
2008 J jnl
Commun. ACM
Edgar A. Whitley, Ian Hosein
2007 J jnl
Inf. Soc.
Edgar A. Whitley, Ian Hosein, Ian O. Angell, Simon Davies
2006 J jnl
Inf. Soc.
Ian Hosein
2005 J jnl
Gov. Inf. Q.
Ian Hosein
2004 J jnl
Commun. ACM
Alberto Escudero-Pascual, Ian Hosein
2004 J jnl
Inf. Soc.
Ian Hosein
2003 conf
ECIS
Prodromos Tsiavos, Ian Hosein
2003
Ian Hosein
2003 conf
Information Systems Perspectives and Challenges in the Context of Globalization
Prodromos Tsiavos, Ian Hosein, Edgar A. Whitley
2002 conf
Global and Organizational Discourse about Information Technology
Ian Hosein
2002 C conf
ICIS
Prodromos Tsiavos, Edgar A. Whitley, Ian Hosein
2002 J jnl
J. Strateg. Inf. Syst.
Ian Hosein, Edgar A. Whitley
2001 conf
Realigning Research and Practice in Information Systems Development
Carsten Sørensen, Edgar A. Whitley, Shirin Madon, Dasha Klyachko, Ian Hosein, Justine Johnstone
2001 conf
Realigning Research and Practice in Information Systems Development
Edgar A. Whitley, Ian Hosein
redb/settings/elasticsearch.py
← Index redb/settings/elasticsearch.py python
import logging
import os

from elasticsearch import Elasticsearch
from dotenv import load_dotenv

load_dotenv()

# Elasticsearch configuration
ELASTIC_ENDPOINT = os.getenv("ELASTIC_HOST")
ELASTIC_ENFORCE_SSL = os.getenv("ELASTIC_ENFORCE_SSL", False) == "True"
ELASTIC_USER = os.getenv("ELASTIC_USER")
ELASTIC_PASSWORD = os.getenv("ELASTIC_PASSWORD")
ELASTIC_BINARIES_COLLECTION = os.getenv("ELASTIC_BINARIES_COLLECTION", "test_db")

# Cached client instance
_elasticsearch_client = None

def get_elasticsearch_client():
    """Get Elasticsearch client with lazy initialization and caching"""
    global _elasticsearch_client
    
    if _elasticsearch_client is None:
        if not ELASTIC_ENDPOINT:
            raise ValueError("ELASTIC_HOST environment variable is required for Elasticsearch connection")
            
        _elasticsearch_client = Elasticsearch(
            ELASTIC_ENDPOINT,
            verify_certs=ELASTIC_ENFORCE_SSL,
            basic_auth=(ELASTIC_USER, ELASTIC_PASSWORD),
            maxsize=20,
            retry_on_timeout=True,
            timeout=30,
        )
    
    return _elasticsearch_client

def create_elasticsearch_client():
    """Create a new Elasticsearch client connection (legacy function)"""
    return get_elasticsearch_client()