增加外部接口调用开关
This commit is contained in:
@@ -13,6 +13,7 @@ class Settings(BaseSettings):
|
||||
|
||||
# 业务配置
|
||||
count_threshold: int = 3 # count阈值,大于等于此值直接返回
|
||||
external_api_enabled: bool = False # 是否启用外部API调用
|
||||
external_api_retry_max: int = 3 # 外部API最大重试次数
|
||||
external_api_url: str = ""
|
||||
|
||||
@@ -26,6 +27,7 @@ class Settings(BaseSettings):
|
||||
|
||||
# 应用配置
|
||||
app_name: str = "AI Talk Callback API"
|
||||
environment: str = "production" # 环境: production, test, development
|
||||
debug: bool = False
|
||||
|
||||
class Config:
|
||||
|
||||
@@ -256,6 +256,17 @@ async def ai_talk_callback(
|
||||
site_id=siteId
|
||||
)
|
||||
|
||||
# 检查是否启用外部API调用
|
||||
if not settings.external_api_enabled:
|
||||
logger.info(f"🔌 外部API调用已禁用,直接返回成功")
|
||||
return CallbackResponse(
|
||||
success=True,
|
||||
message="外部API调用已禁用,直接返回",
|
||||
processed=False,
|
||||
retry_count=0,
|
||||
site_id=siteId
|
||||
)
|
||||
|
||||
logger.info(f"📞 count={callback_data.count} < {settings.count_threshold},调用外部API")
|
||||
|
||||
# count < 3,调用外部API,使用分布式锁防止并发调用
|
||||
|
||||
Reference in New Issue
Block a user