This commit is contained in:
@@ -13,6 +13,7 @@ class Settings:
|
||||
session_ttl_seconds: int
|
||||
database_url: str
|
||||
redis_url: str
|
||||
history_cache: str
|
||||
|
||||
|
||||
def _secret(file_var: str, value_var: str) -> str:
|
||||
@@ -32,6 +33,13 @@ def _secret(file_var: str, value_var: str) -> str:
|
||||
return value
|
||||
|
||||
|
||||
def _history_cache() -> str:
|
||||
mode = os.getenv('HISTORY_CACHE', 'protected').strip().lower() or 'protected'
|
||||
if mode not in ('protected', 'naive', 'off'):
|
||||
raise RuntimeError('HISTORY_CACHE must be protected, naive or off')
|
||||
return mode
|
||||
|
||||
|
||||
def load_settings() -> Settings:
|
||||
return Settings(
|
||||
host=os.getenv('APP_HOST', '0.0.0.0'),
|
||||
@@ -42,4 +50,5 @@ def load_settings() -> Settings:
|
||||
session_ttl_seconds=int(os.getenv('SESSION_TTL_SECONDS', '3600')),
|
||||
database_url=_secret('DATABASE_URL_FILE', 'DATABASE_URL'),
|
||||
redis_url=_secret('CACHE_URL_FILE', 'REDIS_URL'),
|
||||
history_cache=_history_cache(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user