modify: 微服务演进
This commit is contained in:
+10
-3
@@ -22,7 +22,7 @@ import httpx
|
||||
import orjson
|
||||
from fastapi import FastAPI
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(REPO_ROOT / "src"))
|
||||
sys.path.insert(0, str(REPO_ROOT / "utils" / "worker" / "src"))
|
||||
|
||||
@@ -53,6 +53,11 @@ _cs_mod = importlib.util.module_from_spec(_cs_spec)
|
||||
sys.modules["chongming.app.core.call_stats"] = _cs_mod
|
||||
_cs_spec.loader.exec_module(_cs_mod) # type: ignore[union-attr]
|
||||
|
||||
# 审计采样率固定为全量:生产 config 的 access_sample_rate=0.1 下,成功请求的审计行
|
||||
# 本就是按概率写的,断言"几条请求 = 几条审计行"会随机失败。本测试验证的是审计链路
|
||||
# 是否工作,与采样策略无关,故固定为 1.0。
|
||||
_cs_mod._AUDIT_SAMPLE_RATE = 1.0
|
||||
|
||||
# 加载真实 route_generator
|
||||
_rg_path = REPO_ROOT / "src" / "chongming" / "app" / "core" / "route_generator.py"
|
||||
_rg_spec = importlib.util.spec_from_file_location("chongming.app.core.route_generator", _rg_path)
|
||||
@@ -95,12 +100,14 @@ class FakeWorkerManager:
|
||||
self.reply = reply
|
||||
self.error = error
|
||||
|
||||
async def call_raw(self, worker_type, subject, payload, timeout=3.0, retries=1, cacheable=False):
|
||||
async def call_raw(self, worker_type, subject, payload, timeout=3.0, retries=1, cacheable=False,
|
||||
instance_id=None):
|
||||
if self.error == "no_worker":
|
||||
raise RuntimeError(f"类型 '{worker_type}' 没有可用 Worker。")
|
||||
return self.reply
|
||||
|
||||
async def call_stream(self, worker_type, subject, payload, timeout=300.0, idle_timeout=10.0):
|
||||
async def call_stream(self, worker_type, subject, payload, timeout=300.0, idle_timeout=10.0,
|
||||
instance_id=None):
|
||||
if self.error == "no_worker":
|
||||
raise RuntimeError(f"类型 '{worker_type}' 没有可用 Worker。")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user