mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-06 04:10:02 +08:00
bugfix:更换数据库初始化超时路径以修复连接超时问题 (#2137)
* bugfix:更换数据库初始化超时路径以修复连接超时问题 * 移除部分观测链路 * 细节修改 * 权限检查细节修改2 * bugfix:修复金币懒加载造成插件金币消耗不了的问题 * bugfix:整理鉴权逻辑 * 完善缓存系统 * 优化官端使用 * bugfix:增加官机和频道的前导统一剥离,新增获取群列表自愈 * bugfix:修复导入问题
This commit is contained in:
@@ -1,113 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections import deque
|
||||
import contextlib
|
||||
import time
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .bot_message_store import BotMessageStore
|
||||
|
||||
LOG_COMMAND = "BotMessageStore"
|
||||
|
||||
_BUFFER_MAX_RETAIN = 20_000
|
||||
_FLUSH_TRIGGER_SIZE = 64
|
||||
_FLUSH_BATCH_SIZE = 500
|
||||
_FLUSH_INTERVAL_SECONDS = 5.0
|
||||
_DROP_LOG_INTERVAL_SECONDS = 10.0
|
||||
|
||||
_buffer: deque[BotMessageStore] = deque()
|
||||
_buffer_lock = asyncio.Lock()
|
||||
_flush_lock = asyncio.Lock()
|
||||
_flush_task: asyncio.Task[None] | None = None
|
||||
_dropped = 0
|
||||
_last_drop_log_at = 0.0
|
||||
|
||||
|
||||
def _ensure_flush_task() -> None:
|
||||
global _flush_task
|
||||
if _flush_task is not None and not _flush_task.done():
|
||||
return
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
return
|
||||
_flush_task = loop.create_task(_flush_loop())
|
||||
|
||||
|
||||
def _record_drop() -> None:
|
||||
global _dropped, _last_drop_log_at
|
||||
_dropped += 1
|
||||
now = time.monotonic()
|
||||
if now - _last_drop_log_at < _DROP_LOG_INTERVAL_SECONDS:
|
||||
return
|
||||
_last_drop_log_at = now
|
||||
logger.warning(
|
||||
f"bot_message_store buffer full, dropped {_dropped} records, "
|
||||
f"backlog={len(_buffer)}",
|
||||
LOG_COMMAND,
|
||||
)
|
||||
|
||||
|
||||
async def _flush_loop() -> None:
|
||||
while True:
|
||||
await asyncio.sleep(_FLUSH_INTERVAL_SECONDS)
|
||||
try:
|
||||
await flush_bot_message_store_buffer("定时")
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception as exc:
|
||||
logger.warning("定时批量写入 Bot 发送记录失败", LOG_COMMAND, e=exc)
|
||||
|
||||
|
||||
async def append_bot_message_store_record(record: BotMessageStore) -> None:
|
||||
_ensure_flush_task()
|
||||
async with _buffer_lock:
|
||||
if len(_buffer) >= _BUFFER_MAX_RETAIN:
|
||||
_buffer.popleft()
|
||||
_record_drop()
|
||||
_buffer.append(record)
|
||||
should_flush = len(_buffer) >= _FLUSH_TRIGGER_SIZE and not _flush_lock.locked()
|
||||
if should_flush:
|
||||
await flush_bot_message_store_buffer("缓冲区触发")
|
||||
|
||||
|
||||
async def flush_bot_message_store_buffer(reason: str) -> int:
|
||||
from .bot_message_store import BotMessageStore
|
||||
|
||||
async with _flush_lock:
|
||||
written = 0
|
||||
while True:
|
||||
batch: list[BotMessageStore] = []
|
||||
async with _buffer_lock:
|
||||
while _buffer and len(batch) < _FLUSH_BATCH_SIZE:
|
||||
batch.append(_buffer.popleft())
|
||||
if not batch:
|
||||
break
|
||||
try:
|
||||
await BotMessageStore.bulk_create(batch, batch_size=_FLUSH_BATCH_SIZE)
|
||||
except Exception as exc:
|
||||
async with _buffer_lock:
|
||||
retain_count = max(_BUFFER_MAX_RETAIN - len(_buffer), 0)
|
||||
for record in reversed(batch[-retain_count:]):
|
||||
_buffer.appendleft(record)
|
||||
logger.error(f"{reason}批量写入 Bot 发送记录失败", LOG_COMMAND, e=exc)
|
||||
return written
|
||||
written += len(batch)
|
||||
if written:
|
||||
logger.debug(f"{reason}批量写入 Bot 发送记录 {written} 条", LOG_COMMAND)
|
||||
return written
|
||||
|
||||
|
||||
async def stop_bot_message_store_buffer() -> int:
|
||||
global _flush_task
|
||||
task = _flush_task
|
||||
_flush_task = None
|
||||
if task is not None:
|
||||
task.cancel()
|
||||
with contextlib.suppress(BaseException):
|
||||
await task
|
||||
return await flush_bot_message_store_buffer("关闭")
|
||||
@@ -1,49 +0,0 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from tortoise import fields
|
||||
|
||||
from zhenxun.services.db_context import Model
|
||||
|
||||
|
||||
class AuthDecisionLog(Model):
|
||||
id = fields.IntField(pk=True, generated=True, auto_increment=True)
|
||||
"""自增id"""
|
||||
bot_id = fields.CharField(255, null=True, description="Bot ID")
|
||||
"""Bot ID"""
|
||||
platform = fields.CharField(64, null=True, description="平台")
|
||||
"""平台"""
|
||||
group_id = fields.CharField(255, null=True, description="群组id")
|
||||
"""群组id"""
|
||||
user_id = fields.CharField(255, null=True, description="用户id")
|
||||
"""用户id"""
|
||||
module = fields.CharField(255, null=True, description="插件模块")
|
||||
"""插件模块"""
|
||||
effect = fields.CharField(32, description="决策结果")
|
||||
"""决策结果 allow/deny/skip/defer/error"""
|
||||
reason = fields.CharField(255, null=True, description="原因")
|
||||
"""原因"""
|
||||
shadow_effect = fields.CharField(32, null=True, description="影子决策结果")
|
||||
"""影子决策结果"""
|
||||
shadow_reason = fields.CharField(255, null=True, description="影子决策原因")
|
||||
"""影子决策原因"""
|
||||
side_effect_state = fields.TextField(null=True, description="副作用状态")
|
||||
"""副作用状态 JSON 摘要"""
|
||||
latency_ms = fields.FloatField(default=0, description="耗时毫秒")
|
||||
"""耗时毫秒"""
|
||||
overloaded = fields.BooleanField(default=False, description="是否过载")
|
||||
"""是否过载"""
|
||||
create_time = fields.DatetimeField(auto_now_add=True, description="创建时间")
|
||||
"""创建时间"""
|
||||
|
||||
class Meta: # pyright: ignore [reportIncompatibleVariableOverride]
|
||||
table = "auth_decision_log"
|
||||
table_description = "权限决策追加审计日志"
|
||||
indexes: ClassVar = [
|
||||
("create_time",),
|
||||
("module", "create_time"),
|
||||
("effect", "create_time"),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
async def _run_script(cls):
|
||||
return []
|
||||
@@ -3,6 +3,7 @@ from typing import ClassVar
|
||||
from typing_extensions import Self
|
||||
|
||||
from tortoise import fields
|
||||
from tortoise.expressions import Q
|
||||
|
||||
from zhenxun.services.cache import CacheException, CacheRegistry, CacheRoot
|
||||
from zhenxun.services.cache.runtime_cache import BanMemoryCache
|
||||
@@ -89,15 +90,18 @@ class BanConsole(Model):
|
||||
cls._ensure_cache_registered()
|
||||
if not user_id and not group_id:
|
||||
raise UserAndGroupIsNone()
|
||||
dao = DataAccess(cls)
|
||||
if user_id:
|
||||
dao = DataAccess(cls)
|
||||
return (
|
||||
await dao.safe_get_or_none(user_id=user_id, group_id=group_id)
|
||||
if group_id
|
||||
else await dao.safe_get_or_none(user_id=user_id, group_id__isnull=True)
|
||||
)
|
||||
else:
|
||||
return await dao.safe_get_or_none(user_id="", group_id=group_id)
|
||||
return await cls.safe_get_or_none(
|
||||
Q(user_id__isnull=True) | Q(user_id=""),
|
||||
group_id=group_id,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def check_ban_level(
|
||||
|
||||
@@ -26,7 +26,7 @@ class BotConsole(Model):
|
||||
available_plugins = fields.TextField(default="", description="可用插件")
|
||||
"""可用插件"""
|
||||
available_tasks = fields.TextField(default="", description="可用被动技能")
|
||||
"""可用被动技能"""
|
||||
"""可用被动技能管理镜像,不作为运行白名单。"""
|
||||
|
||||
class Meta: # pyright: ignore [reportIncompatibleVariableOverride]
|
||||
table = "bot_console"
|
||||
@@ -87,7 +87,11 @@ class BotConsole(Model):
|
||||
@classmethod
|
||||
async def get_tasks(cls, bot_id: str | None = None, status: bool | None = True):
|
||||
"""
|
||||
获取bot被动技能
|
||||
获取bot被动技能管理镜像。
|
||||
|
||||
available_tasks 只服务管理命令和展示,不参与运行白名单判断。
|
||||
被动运行真源是 TaskInfo.status/load_status、BotConsole.block_tasks、
|
||||
GroupConsole.block_task/superuser_block_task。
|
||||
|
||||
参数:
|
||||
bot_id (str | None, optional): bot_id. Defaults to None.
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
from tortoise import fields
|
||||
|
||||
from zhenxun.services.db_context import Model
|
||||
from zhenxun.utils.enum import BotSentType
|
||||
|
||||
from ._bot_message_buffer import append_bot_message_store_record
|
||||
|
||||
|
||||
class BotMessageStore(Model):
|
||||
id = fields.IntField(pk=True, generated=True, auto_increment=True)
|
||||
"""自增id"""
|
||||
bot_id = fields.CharField(255, null=True)
|
||||
"""bot id"""
|
||||
user_id = fields.CharField(255, null=True)
|
||||
"""目标id"""
|
||||
group_id = fields.CharField(255, null=True)
|
||||
"""群组id"""
|
||||
sent_type = fields.CharEnumField(BotSentType)
|
||||
"""类型"""
|
||||
text = fields.TextField(null=True)
|
||||
"""文本内容"""
|
||||
plain_text = fields.TextField(null=True)
|
||||
"""纯文本"""
|
||||
platform = fields.CharField(255, null=True)
|
||||
"""平台"""
|
||||
create_time = fields.DatetimeField(auto_now_add=True)
|
||||
"""创建时间"""
|
||||
|
||||
class Meta: # pyright: ignore [reportIncompatibleVariableOverride]
|
||||
table = "bot_message_store"
|
||||
table_description = "Bot发送消息列表"
|
||||
|
||||
@classmethod
|
||||
async def append_buffered(
|
||||
cls,
|
||||
*,
|
||||
bot_id: str | None = None,
|
||||
user_id: str | None = None,
|
||||
group_id: str | None = None,
|
||||
sent_type: BotSentType,
|
||||
text: str | None = None,
|
||||
plain_text: str | None = None,
|
||||
platform: str | None = None,
|
||||
) -> None:
|
||||
await append_bot_message_store_record(
|
||||
cls(
|
||||
bot_id=bot_id,
|
||||
user_id=user_id,
|
||||
group_id=group_id,
|
||||
sent_type=sent_type,
|
||||
text=text,
|
||||
plain_text=plain_text,
|
||||
platform=platform,
|
||||
)
|
||||
)
|
||||
@@ -151,8 +151,10 @@ class FgRequest(Model):
|
||||
"添加好友自动发送BOT自我介绍图片", session=req.user_id
|
||||
)
|
||||
else:
|
||||
await GroupConsole.update_or_create(
|
||||
group_id=req.group_id, defaults={"group_flag": 1}
|
||||
await GroupConsole.get_or_create_root_group(
|
||||
group_id=req.group_id,
|
||||
defaults={"group_flag": 1},
|
||||
update_defaults=True,
|
||||
)
|
||||
if req.flag == "0":
|
||||
# 用户手动申请入群,创建群认证后提醒用户拉群
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from typing import TYPE_CHECKING, Any, ClassVar, cast, overload
|
||||
from typing_extensions import Self
|
||||
|
||||
@@ -103,6 +104,8 @@ class GroupConsole(Model):
|
||||
"""缓存键字段"""
|
||||
enable_lock: ClassVar[list[DbLockType]] = [DbLockType.CREATE, DbLockType.UPSERT]
|
||||
"""开启锁"""
|
||||
_root_group_locks: ClassVar[dict[str, asyncio.Lock]] = {}
|
||||
"""普通群记录应用层锁,规避 channel_id=NULL 唯一键语义差异。"""
|
||||
|
||||
@classmethod
|
||||
async def _get_task_modules(cls, *, default_status: bool) -> list[str]:
|
||||
@@ -250,6 +253,143 @@ class GroupConsole(Model):
|
||||
|
||||
return group, is_create
|
||||
|
||||
@classmethod
|
||||
def _clean_root_group_defaults(cls, defaults: dict | None) -> dict[str, Any]:
|
||||
cleaned = {}
|
||||
for field, value in (defaults or {}).items():
|
||||
if field in {"id", "group_id", "channel_id", "channel_id__isnull"}:
|
||||
continue
|
||||
if value is None:
|
||||
continue
|
||||
cleaned[field] = value
|
||||
return cleaned
|
||||
|
||||
@classmethod
|
||||
def _root_group_score(cls, group: Self) -> tuple[int, int]:
|
||||
score = 0
|
||||
score += 8 if group.group_name else 0
|
||||
score += 4 if group.max_member_count else 0
|
||||
score += 4 if group.member_count else 0
|
||||
score += 4 if group.group_flag else 0
|
||||
score += 4 if group.is_super else 0
|
||||
score += 3 if not group.status else 0
|
||||
score += 3 if group.level != 5 else 0
|
||||
score += len(convert_module_format(group.block_plugin))
|
||||
score += len(convert_module_format(group.superuser_block_plugin))
|
||||
score += len(convert_module_format(group.block_task))
|
||||
score += len(convert_module_format(group.superuser_block_task))
|
||||
return score, int(group.id or 0)
|
||||
|
||||
@classmethod
|
||||
def _merge_module_field(cls, groups: list[Self], field: str) -> str:
|
||||
modules: list[str] = []
|
||||
seen = set()
|
||||
for group in groups:
|
||||
value = getattr(group, field, "") or ""
|
||||
for module in cast(list[str], convert_module_format(value)):
|
||||
if module not in seen:
|
||||
seen.add(module)
|
||||
modules.append(module)
|
||||
return cast(str, convert_module_format(modules))
|
||||
|
||||
@classmethod
|
||||
async def _deduplicate_root_group_records(cls, groups: list[Self]) -> Self:
|
||||
if len(groups) == 1:
|
||||
return groups[0]
|
||||
|
||||
keep = max(groups, key=cls._root_group_score)
|
||||
newest_first = sorted(
|
||||
groups, key=lambda group: int(group.id or 0), reverse=True
|
||||
)
|
||||
|
||||
merged = {
|
||||
"group_name": next(
|
||||
(g.group_name for g in newest_first if g.group_name), ""
|
||||
),
|
||||
"max_member_count": max(g.max_member_count for g in groups),
|
||||
"member_count": max(g.member_count for g in groups),
|
||||
"status": all(g.status for g in groups),
|
||||
"level": min(g.level for g in groups),
|
||||
"is_super": any(g.is_super for g in groups),
|
||||
"group_flag": max(g.group_flag for g in groups),
|
||||
"block_plugin": cls._merge_module_field(groups, "block_plugin"),
|
||||
"superuser_block_plugin": cls._merge_module_field(
|
||||
groups, "superuser_block_plugin"
|
||||
),
|
||||
"block_task": cls._merge_module_field(groups, "block_task"),
|
||||
"superuser_block_task": cls._merge_module_field(
|
||||
groups, "superuser_block_task"
|
||||
),
|
||||
"platform": next((g.platform for g in newest_first if g.platform), "qq"),
|
||||
}
|
||||
|
||||
update_fields = []
|
||||
for field, value in merged.items():
|
||||
if getattr(keep, field) != value:
|
||||
setattr(keep, field, value)
|
||||
update_fields.append(field)
|
||||
if update_fields:
|
||||
await keep.save(update_fields=update_fields)
|
||||
|
||||
for group in groups:
|
||||
if group.id != keep.id:
|
||||
await group.delete()
|
||||
await GroupMemoryCache.upsert_from_model(keep)
|
||||
return keep
|
||||
|
||||
@classmethod
|
||||
async def get_or_create_root_group(
|
||||
cls,
|
||||
group_id: str | int,
|
||||
defaults: dict | None = None,
|
||||
*,
|
||||
update_defaults: bool = False,
|
||||
) -> tuple[Self, bool]:
|
||||
"""获取或创建普通群记录,并收敛 channel_id=NULL 重复数据。
|
||||
|
||||
普通群固定使用 ``channel_id IS NULL``;频道记录必须继续显式传
|
||||
``channel_id`` 走原有 get_or_create/update_or_create。
|
||||
"""
|
||||
gid = str(group_id).strip()
|
||||
if not gid:
|
||||
raise ValueError("group_id cannot be empty")
|
||||
|
||||
lock = cls._root_group_locks.setdefault(gid, asyncio.Lock())
|
||||
async with lock:
|
||||
defaults = cls._clean_root_group_defaults(defaults)
|
||||
records = await cls.filter(group_id=gid, channel_id__isnull=True).all()
|
||||
if records:
|
||||
group = await cls._deduplicate_root_group_records(records)
|
||||
if update_defaults:
|
||||
update_fields = []
|
||||
for field, value in defaults.items():
|
||||
if hasattr(group, field) and getattr(group, field) != value:
|
||||
setattr(group, field, value)
|
||||
update_fields.append(field)
|
||||
if update_fields:
|
||||
await group.save(update_fields=update_fields)
|
||||
await GroupMemoryCache.upsert_from_model(group)
|
||||
return group, False
|
||||
|
||||
group = await cls.create(group_id=gid, channel_id=None, **defaults)
|
||||
return group, True
|
||||
|
||||
@classmethod
|
||||
async def _get_or_create_group_for_write(
|
||||
cls,
|
||||
group_id: str,
|
||||
channel_id: str | None,
|
||||
defaults: dict | None = None,
|
||||
) -> tuple[Self, bool]:
|
||||
defaults = cls._clean_root_group_defaults(defaults)
|
||||
if channel_id:
|
||||
return await cls.get_or_create(
|
||||
group_id=group_id,
|
||||
channel_id=channel_id,
|
||||
defaults=defaults,
|
||||
)
|
||||
return await cls.get_or_create_root_group(group_id, defaults=defaults)
|
||||
|
||||
async def save(self, *args, **kwargs):
|
||||
await super().save(*args, **kwargs)
|
||||
await GroupMemoryCache.upsert_from_model(self)
|
||||
@@ -326,6 +466,7 @@ class GroupConsole(Model):
|
||||
module: str,
|
||||
is_superuser: bool = False,
|
||||
platform: str | None = None,
|
||||
channel_id: str | None = None,
|
||||
):
|
||||
"""禁用群组插件
|
||||
|
||||
@@ -335,8 +476,10 @@ class GroupConsole(Model):
|
||||
is_superuser: 是否为超级用户
|
||||
platform: 平台
|
||||
"""
|
||||
group, _ = await cls.get_or_create(
|
||||
group_id=group_id, defaults={"platform": platform}
|
||||
group, _ = await cls._get_or_create_group_for_write(
|
||||
group_id=group_id,
|
||||
channel_id=channel_id,
|
||||
defaults={"platform": platform},
|
||||
)
|
||||
update_fields = []
|
||||
if is_superuser:
|
||||
@@ -365,6 +508,7 @@ class GroupConsole(Model):
|
||||
module: str,
|
||||
is_superuser: bool = False,
|
||||
platform: str | None = None,
|
||||
channel_id: str | None = None,
|
||||
):
|
||||
"""禁用群组插件
|
||||
|
||||
@@ -374,8 +518,10 @@ class GroupConsole(Model):
|
||||
is_superuser: 是否为超级用户
|
||||
platform: 平台
|
||||
"""
|
||||
group, _ = await cls.get_or_create(
|
||||
group_id=group_id, defaults={"platform": platform}
|
||||
group, _ = await cls._get_or_create_group_for_write(
|
||||
group_id=group_id,
|
||||
channel_id=channel_id,
|
||||
defaults={"platform": platform},
|
||||
)
|
||||
update_fields = []
|
||||
if is_superuser:
|
||||
@@ -447,6 +593,7 @@ class GroupConsole(Model):
|
||||
task: str,
|
||||
is_superuser: bool = False,
|
||||
platform: str | None = None,
|
||||
channel_id: str | None = None,
|
||||
):
|
||||
"""禁用群组插件
|
||||
|
||||
@@ -456,13 +603,15 @@ class GroupConsole(Model):
|
||||
is_superuser: 是否为超级用户
|
||||
platform: 平台
|
||||
"""
|
||||
group, _ = await cls.get_or_create(
|
||||
group_id=group_id, defaults={"platform": platform}
|
||||
group, _ = await cls._get_or_create_group_for_write(
|
||||
group_id=group_id,
|
||||
channel_id=channel_id,
|
||||
defaults={"platform": platform},
|
||||
)
|
||||
update_fields = []
|
||||
if is_superuser:
|
||||
superuser_block_task = convert_module_format(group.superuser_block_task)
|
||||
if task not in group.superuser_block_task:
|
||||
if task not in superuser_block_task:
|
||||
superuser_block_task.append(task)
|
||||
group.superuser_block_task = convert_module_format(superuser_block_task)
|
||||
update_fields.append("superuser_block_task")
|
||||
@@ -484,6 +633,7 @@ class GroupConsole(Model):
|
||||
task: str,
|
||||
is_superuser: bool = False,
|
||||
platform: str | None = None,
|
||||
channel_id: str | None = None,
|
||||
):
|
||||
"""禁用群组插件
|
||||
|
||||
@@ -493,8 +643,10 @@ class GroupConsole(Model):
|
||||
is_superuser: 是否为超级用户
|
||||
platform: 平台
|
||||
"""
|
||||
group, _ = await cls.get_or_create(
|
||||
group_id=group_id, defaults={"platform": platform}
|
||||
group, _ = await cls._get_or_create_group_for_write(
|
||||
group_id=group_id,
|
||||
channel_id=channel_id,
|
||||
defaults={"platform": platform},
|
||||
)
|
||||
update_fields = []
|
||||
if is_superuser:
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from tortoise import fields
|
||||
|
||||
from zhenxun.services.db_context import Model
|
||||
|
||||
|
||||
class RuntimeBackpressureLog(Model):
|
||||
id = fields.IntField(pk=True, generated=True, auto_increment=True)
|
||||
"""自增id"""
|
||||
scope_key = fields.CharField(255, null=True, description="作用域")
|
||||
"""作用域"""
|
||||
reason = fields.CharField(255, null=True, description="原因")
|
||||
"""原因"""
|
||||
lane = fields.CharField(64, null=True, description="调度通道")
|
||||
"""调度通道"""
|
||||
action = fields.CharField(64, description="处理动作")
|
||||
"""处理动作 execute/skip/defer/signal"""
|
||||
queue_size = fields.IntField(default=0, description="队列长度")
|
||||
"""队列长度"""
|
||||
active_count = fields.IntField(default=0, description="活跃数量")
|
||||
"""活跃数量"""
|
||||
duration_ms = fields.FloatField(default=0, description="持续耗时毫秒")
|
||||
"""持续耗时毫秒"""
|
||||
create_time = fields.DatetimeField(auto_now_add=True, description="创建时间")
|
||||
"""创建时间"""
|
||||
|
||||
class Meta: # pyright: ignore [reportIncompatibleVariableOverride]
|
||||
table = "runtime_backpressure_log"
|
||||
table_description = "运行时背压追加审计日志"
|
||||
indexes: ClassVar = [
|
||||
("create_time",),
|
||||
("scope_key", "create_time"),
|
||||
("lane", "create_time"),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
async def _run_script(cls):
|
||||
return []
|
||||
@@ -219,6 +219,7 @@ class UserConsole(Model):
|
||||
)
|
||||
if not updated:
|
||||
raise InsufficientGold()
|
||||
await cls.invalidate_user_cache(user_id)
|
||||
return GoldReservation(
|
||||
user_id=user_id,
|
||||
gold=gold,
|
||||
|
||||
Reference in New Issue
Block a user