ForcePilot/backend/package/yuxi/channels/contract/dtos/route_events.py
Kris 6ddc2a8c25 feat: 新增批量配置查询、路由绑定管理等功能并优化现有逻辑
1. 新增config/get_many批量配置查询接口与Redis实现
2. 新增路由绑定相关端口与事件校验
3. 优化插件目录展示,新增last_error与重启提示字段
4. 新增插件配置更新与重启状态跟踪逻辑
5. 优化会话搜索参数支持,新增account_id过滤
6. 替换部分ValueError为ValidationError统一错误类型
7. 新增多类DTO与参数校验逻辑
8. 优化SQLAlchemy事务处理与乐观锁实现
9. 新增能力画像矩阵过滤功能
2026-07-11 15:52:20 +08:00

52 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""路由绑定领域事件 DTO。
定义路由绑定变更事件 payload由 RouteBindingHandler 在 create/update/delete
成功后发布RouteMatchRegistryLoader 订阅并刷新对应账户的内存注册表。
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Literal
from yuxi.channels.contract.dtos.channel import ChannelType
from yuxi.channels.contract.errors import ValidationError
__all__ = ["ROUTE_BINDING_CHANGED", "RouteBindingChangedEvent"]
#: 路由绑定变更事件类型标识。
ROUTE_BINDING_CHANGED = "RouteBindingChanged"
@dataclass(frozen=True)
class RouteBindingChangedEvent:
"""路由绑定变更事件 payload。
由 RouteBindingHandler 在 create/update/delete 成功后发布,
RouteMatchRegistryLoader 订阅并刷新对应账户的内存注册表。
字段:
binding_id: 变更的绑定规则业务主键。
channel_type: 渠道类型。
account_id: 渠道账户 ID。
change_type: 变更类型created / updated / deleted
"""
binding_id: str
channel_type: ChannelType
account_id: str
change_type: Literal["created", "updated", "deleted"]
def __post_init__(self) -> None:
"""校验 binding_id / account_id 非空与 channel_type 非 None。
事件 payload 中的定位字段必须有效,在构造时即抛出
``ValidationError``避免空值事件进入事件总线INV-8
"""
if not self.binding_id:
raise ValidationError("binding_id", "must not be empty")
if self.channel_type is None:
raise ValidationError("channel_type", "must not be None")
if not self.account_id:
raise ValidationError("account_id", "must not be empty")