"""
Default settings and operational constants for the search engine.

All parameters defined here can be overridden in the main Django `settings.py`
file by prefixing the variable name with 'DDS_'.
"""

from dataclasses import dataclass
from django.conf import settings


@dataclass(frozen=True)
class Defaults:
    """
    Immutable container holding default configuration values for batch processing,
    memory estimation, and cache limits.
    """

    # Target fraction of available system RAM to utilize during large searches
    MEMORY_FRACTION: float = getattr(settings, "DDS_MEMORY_FRACTION", 0.60)

    # Default Time-To-Live (TTL) in seconds for cached search results
    CACHE_TIMEOUT: int = getattr(settings, "DDS_CACHE_TIMEOUT", 600)

    # Fallback byte size used if dynamic object size estimation fails
    AVG_OBJ_SIZE_FALLBACK: int = getattr(settings, "DDS_AVG_OBJ_SIZE_FALLBACK", 4096)

    # Minimum and maximum boundaries for memory batch processing
    MIN_BATCH_SIZE: int = getattr(settings, "DDS_MIN_BATCH_SIZE", 1_024)
    MAX_BATCH_SIZE: int = getattr(settings, "DDS_MAX_BATCH_SIZE", 1_024_000)

    # Minimum and maximum boundaries for multiprocessing chunks
    MIN_CHUNKSIZE: int = getattr(settings, "DDS_MIN_CHUNKSIZE", 256)
    MAX_CHUNKSIZE: int = getattr(settings, "DDS_MAX_CHUNKSIZE", 15_360)


DEFAULTS = Defaults()
