71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""项目配置,通过 .env 文件覆盖默认值"""
|
|
|
|
# 环境
|
|
env: str = "dev"
|
|
|
|
# ──────────── PostgreSQL(本地,app_job_data 源库)────────────
|
|
pg_host: str = "192.168.31.51"
|
|
pg_port: int = 5432
|
|
pg_user: str = "postgres"
|
|
pg_password: str = ""
|
|
pg_db: str = "postgres"
|
|
pg_pool_size: int = 10
|
|
pg_max_overflow: int = 20
|
|
|
|
# ──────────── MySQL(业务库)────────────
|
|
db_host: str = "192.168.31.105"
|
|
db_port: int = 3306
|
|
db_user: str = "root"
|
|
db_password: str = "123456"
|
|
db_name: str = "offerpie"
|
|
mysql_pool_size: int = 10
|
|
mysql_max_overflow: int = 20
|
|
|
|
# ──────────── AI 供应商 ────────────
|
|
volcengine_api_key: str = "fd065993-bee2-4f31-8bf2-56d5d3012c02"
|
|
volcengine_base_url: str = "https://ark.cn-beijing.volces.com/api/v3"
|
|
|
|
# ──────────── 岗位清洗参数 ────────────
|
|
clean_batch_size: int = 100
|
|
clean_concurrency: int = 50
|
|
clean_interval_seconds: int = 180
|
|
|
|
# ──────────── 公司补充参数 ────────────
|
|
company_batch_size: int = 20
|
|
company_concurrency: int = 10
|
|
company_interval_seconds: int = 300
|
|
|
|
# ──────────── 岗位下架参数 ────────────
|
|
job_expire_days: int = 7
|
|
|
|
# ──────────── 日志 ────────────
|
|
logging_level: str = "INFO"
|
|
log_file_name: str = "cleaner.log"
|
|
|
|
@property
|
|
def pg_url(self) -> str:
|
|
from urllib.parse import quote
|
|
return (
|
|
f"postgresql+asyncpg://{self.pg_user}:{quote(self.pg_password, safe='')}"
|
|
f"@{self.pg_host}:{self.pg_port}/{self.pg_db}"
|
|
)
|
|
|
|
@property
|
|
def mysql_url(self) -> str:
|
|
from urllib.parse import quote
|
|
return (
|
|
f"mysql+asyncmy://{self.db_user}:{quote(self.db_password, safe='')}"
|
|
f"@{self.db_host}:{self.db_port}/{self.db_name}"
|
|
)
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
case_sensitive=False,
|
|
extra="ignore",
|
|
)
|