Coverage for server / services / growthbook / config.py: 100%
22 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-04 09:33 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-04 09:33 +0000
1"""
2GrowthBook configuration loaded from environment variables.
3"""
5from enum import Enum
6from functools import lru_cache
7from typing import Optional
9from pydantic_settings import BaseSettings, SettingsConfigDict
12class EvalMode(str, Enum):
13 """How feature flags are evaluated at runtime."""
15 CUTOVER = "cutover"
16 SHADOW = "shadow"
17 LEGACY = "legacy"
20class GrowthBookSettings(BaseSettings):
21 """Self-hosted GrowthBook connection and runtime behavior."""
23 model_config = SettingsConfigDict(env_file=".env", extra="ignore")
25 growthbook_enabled: bool = True
26 growthbook_api_host: str = "http://localhost:3100"
27 growthbook_client_key: str = ""
28 growthbook_decryption_key: Optional[str] = None
29 growthbook_features_ttl_seconds: int = 60
30 growthbook_context_cache_ttl_seconds: int = 300
31 growthbook_service_name: str = "eruditiontx-services-mvp"
32 feature_flag_eval_mode: EvalMode = EvalMode.CUTOVER
33 growthbook_fail_open: bool = False
36@lru_cache
37def get_growthbook_settings() -> GrowthBookSettings:
38 return GrowthBookSettings()