change that GameplayDatabase can have different backends, sqlite and postgresql with a Template example backend

This commit is contained in:
2026-04-08 14:28:39 +02:00
parent a62501cf22
commit 341bb27278
10 changed files with 1660 additions and 708 deletions
+4
View File
@@ -23,11 +23,13 @@ def build_server_from_env(default_snake_type:str) -> Server:
metrics_ttl_sec = env_int('METRICS_TTL_SEC', 900) if metrics_ttl_sec_raw is not None else None
gameplay_db_enabled = env_bool('GAMEPLAY_DB_ENABLED', True)
gameplay_db_backend = os.environ.get('GAMEPLAY_DB_BACKEND', 'sqlite')
gameplay_db_path = os.environ.get(
'GAMEPLAY_DB_PATH',
os.path.join(data_path, 'data', 'database', 'gameplay.sqlite3'),
)
gameplay_db_busy_timeout_ms = env_int('GAMEPLAY_DB_BUSY_TIMEOUT_MS', 5000)
gameplay_db_pg_dsn = os.environ.get('GAMEPLAY_DB_PG_DSN', None)
server = Server(
data_path=data_path,
@@ -39,8 +41,10 @@ def build_server_from_env(default_snake_type:str) -> Server:
metrics_redis_url=metrics_redis_url,
metrics_ttl_sec=metrics_ttl_sec,
gameplay_db_enabled=gameplay_db_enabled,
gameplay_db_backend=gameplay_db_backend,
gameplay_db_path=gameplay_db_path,
gameplay_db_busy_timeout_ms=gameplay_db_busy_timeout_ms,
gameplay_db_pg_dsn=gameplay_db_pg_dsn,
)
if env_bool('STORE_GAME_HISTORY'):