ForcePilot/backend/package/yuxi/channels/contract/dtos/event.py
Kris b88c0ae29e feat(channels): 批量新增多渠道网关限界上下文基础代码与契约
新增完整的 channels 限界上下文模块,包含契约层、领域核心层、应用服务、管道编排、插件体系、基础设施组合根等全层级代码,新增飞书与微信 iLink 渠道插件基础结构,补充各类 DTO、端口协议与领域服务实现。
2026-07-02 03:22:12 +08:00

57 lines
1.9 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。
定义跨层传递的领域事件值对象,供 ``EventPublisherPort`` 发布与订阅者消费。
事件载荷为不可变值对象(``dataclass(frozen=True)``),不泄露领域实体引用。
"""
from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime
@dataclass(frozen=True)
class OutboxStateChangedEvent:
"""发件箱状态变更事件。
描述一条发件箱条目(``OutboxEntry``)的状态迁移,由应用层在 outbox
状态机推进时(``markSent`` / ``markFailed`` / ``markSuppressed`` /
``markSentUnconfirmed`` 等)产出,经 ``EventPublisherPort`` 分发给
订阅者。状态值取自 ``OutboxStatus`` 枚举的字符串形式,便于跨层序列化
与审计。
字段:
entry_id: 发件箱条目 ID``OutboxEntry.outbox_id``)。
old_state: 变更前状态(``OutboxStatus`` 字符串值)。
new_state: 变更后状态(``OutboxStatus`` 字符串值)。
reason: 变更原因(如投递成功、重试失败、栅栏抑制等)。
occurred_at: 事件发生时间。
"""
entry_id: str
old_state: str
new_state: str
reason: str
occurred_at: datetime
@dataclass(frozen=True)
class OutboxEntryPurgedEvent:
"""发件箱条目被物理清理事件。
描述一批发件箱条目(``OutboxEntry``被物理删除purge的事件
调度器定时清理 dead / sent 终态条目时产出,经 ``EventPublisherPort``
分发给订阅者。``entry_ids`` 为本次被清理条目的业务 ID 列表,供下游
做审计、统计与缓存失效等处理。
字段:
entry_ids: 被物理清理的发件箱条目业务 ID 列表(``OutboxEntry.outbox_id``)。
occurred_at: 事件发生时间。
"""
entry_ids: list[str]
occurred_at: datetime
__all__ = ["OutboxStateChangedEvent", "OutboxEntryPurgedEvent"]