mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-08 05:10:01 +08:00
收窄熔断判断范围,修改熔断逻辑 (#2145)
This commit is contained in:
@@ -39,14 +39,8 @@ class HandleEventSelectorDependencies:
|
||||
_HANDLE_EVENT_PATCHED = False
|
||||
_ORIGINAL_HANDLE_EVENT: Callable[..., Awaitable[None]] | None = None
|
||||
_ORIGINAL_ADAPTER_HANDLE_EVENTS: dict[object, object] = {}
|
||||
_MATCHER_DEADLINE_BY_LANE = {
|
||||
"system": 15.0,
|
||||
"command": 12.0,
|
||||
"temp": 15.0,
|
||||
"passive_light": 3.0,
|
||||
"fallback_ai": 5.0,
|
||||
}
|
||||
_DEFAULT_MATCHER_DEADLINE = 5.0
|
||||
_DEFAULT_MATCHER_DEADLINE = 21600.0
|
||||
_MATCHER_DEADLINE_BY_LANE: dict[str, float] = {}
|
||||
|
||||
|
||||
def _matcher_deadline_for_lane(lane: str) -> float:
|
||||
@@ -76,7 +70,6 @@ async def _run_matcher_with_deadline(
|
||||
with anyio_mod.fail_after(timeout):
|
||||
await coro
|
||||
except TimeoutError:
|
||||
signal_overload(20.0)
|
||||
logger.warning(
|
||||
"matcher dispatch timeout: "
|
||||
f"matcher={_matcher_name(matcher)}, lane={lane}, timeout={timeout:.1f}s",
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, fields
|
||||
import os
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
@@ -101,6 +102,22 @@ def _warn_invalid_env(env_name: str, raw: str, exc: Exception) -> None:
|
||||
return
|
||||
|
||||
|
||||
def _default_passive_db_limit() -> int:
|
||||
try:
|
||||
from zhenxun.configs.config import BotConfig
|
||||
|
||||
scheme = urlparse(BotConfig.db_url or "").scheme.lower()
|
||||
except Exception:
|
||||
scheme = ""
|
||||
if scheme == "sqlite":
|
||||
return 1
|
||||
if scheme.startswith("postgres"):
|
||||
return 6
|
||||
if scheme == "mysql":
|
||||
return 4
|
||||
return 2
|
||||
|
||||
|
||||
def _load_config(cls: type, prefix: str):
|
||||
values = {}
|
||||
default_obj = cls()
|
||||
@@ -115,6 +132,9 @@ def _load_config(cls: type, prefix: str):
|
||||
raw = candidate_value
|
||||
break
|
||||
if raw is None or not raw.strip():
|
||||
if cls is AuthDispatchRuntimeConfig and item.name == "passive_db_limit":
|
||||
values[item.name] = _default_passive_db_limit()
|
||||
continue
|
||||
values[item.name] = default
|
||||
continue
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user