설정이 .env(시크릿)+toml(설정)로 갈려 있던 것을 config.local.toml 하나로 통합. DB 비번이 이미 toml 에 있어 분리 기준이 임의적이었고, backend(하우스 패턴)도 toml 단일이라 일관성 확보. 환경별로 바뀌는 값(DB_HOST 등)만 env override 유지. - config_models: NaverConfig(keys 로테이션)·OpenAIConfig·DecodoConfig 추가 - server_configs: 3개 로드, load_dotenv 제거(python-dotenv 의존성도 제거) - proxy/naver/similarity/keyword/worker_main: os.environ → config 객체 참조 - config.local.toml.example: [NaverConfig]/[OpenAIConfig]/[DecodoConfig] 섹션 - .env/.env.example 삭제, README/주석 갱신 (배포는 toml 마운트 or env override) - tests: DecodoConfig 기반으로 갱신 → 전체 44/44 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
from pydantic import BaseModel
|
|
|
|
from config.config_loader import ConfigModel
|
|
|
|
|
|
class WebServerConfig(ConfigModel):
|
|
server_name: str = ""
|
|
port: int = 0
|
|
process_count: int = 1
|
|
is_ssl: bool = False
|
|
is_test: bool = False
|
|
# CORS 허용 오리진(프론트). 비우면 CORS 미적용. 예: ["http://localhost:5173"]
|
|
cors_origins: list[str] = []
|
|
|
|
|
|
class LogConfig(ConfigModel):
|
|
print_console: bool = True
|
|
log_level: str = "debug"
|
|
|
|
|
|
# DB Read/Write 분리 설정.
|
|
# 하나의 논리 DB 에 대해 write(주) / read(복제) 접속 정보를 각각 가진다.
|
|
class MainDBConfig(ConfigModel):
|
|
db_type: str = "postgresql"
|
|
name: str = ""
|
|
write_host: str = ""
|
|
write_port: int = 5432
|
|
write_id: str = ""
|
|
write_pw: str = ""
|
|
read_host: str = ""
|
|
read_port: int = 5432
|
|
read_id: str = ""
|
|
read_pw: str = ""
|
|
show_log: bool = False
|
|
# 커넥션 풀 사이징. 실제 동시 커넥션 상한 = (pool_size + max_overflow) x 엔진수(R/W=2) x 워커수.
|
|
# PostgreSQL max_connections 를 넘지 않도록 설정해야 한다. (예: 10+20=30 x 2 x 5워커 = 300)
|
|
pool_size: int = 10
|
|
max_overflow: int = 20
|
|
# SSL/TLS 모드: ""/"disable"=미사용(로컬), "require"/"verify-ca"/"verify-full"=관리형 DB(RDS/Aurora/Azure).
|
|
sslmode: str = ""
|
|
|
|
|
|
# ── 시크릿(API 키 등)도 TOML 로 통합 관리. config.local.toml 은 미커밋(*.toml). ──
|
|
# 배포는 이 파일을 마운트하거나(권장), 환경별로 바뀌는 값만 env override 한다(DB_HOST 등).
|
|
|
|
|
|
class NaverKey(BaseModel):
|
|
id: str = ""
|
|
secret: str = ""
|
|
|
|
|
|
class NaverConfig(ConfigModel):
|
|
"""네이버 쇼핑 오픈API 키. 여러 개면 429/403 로테이션에 자동 포함."""
|
|
|
|
keys: list[NaverKey] = []
|
|
|
|
|
|
class OpenAIConfig(ConfigModel):
|
|
"""AI 유사도 판정/검색어 생성용 OpenAI."""
|
|
|
|
api_key: str = ""
|
|
model: str = "gpt-4o-mini"
|
|
|
|
|
|
class DecodoConfig(ConfigModel):
|
|
"""DECODO residential 프록시(쿠팡 전용, 포트기반 sticky). 값이 다 차야 활성."""
|
|
|
|
host: str = ""
|
|
username: str = ""
|
|
password: str = ""
|
|
port_start: int = 0
|
|
port_end: int = 0
|
|
session_minutes: int = 10
|