新增完整的 channels 限界上下文模块,包含契约层、领域核心层、应用服务、管道编排、插件体系、基础设施组合根等全层级代码,新增飞书与微信 iLink 渠道插件基础结构,补充各类 DTO、端口协议与领域服务实现。
68 lines
2.8 KiB
Python
68 lines
2.8 KiB
Python
"""应用服务层。
|
||
|
||
应用服务层是 ForcePilot v1.2 多渠道网关的编排层,负责:
|
||
- 用例编排:实现驱动端口用例,协调领域服务与管道执行;
|
||
- 管道装配:装配入站 / 出站 / 控制面管道的阶段序列;
|
||
- 事务边界:在管道或用例编排器中显式控制事务边界;
|
||
- 领域服务编排:调用 core 层领域服务完成业务流程,不在应用层重新实现业务规则。
|
||
|
||
应用层仅依赖契约层(yuxi.channels.contract)与领域核心层(yuxi.channels.core),
|
||
不得直接依赖 fastapi / sqlalchemy / redis / arq 等框架设施。
|
||
|
||
新增子包(从 framework/ 拆解迁移):
|
||
- ``extension/``:扩展点注册中心(StageSlot/EventSubscription/ConfigSource)+ EventBus + 7 个内置事件订阅者。
|
||
- ``lifecycle/``:插件生命周期编排(状态机、加载器、依赖解析、能力校验、生命周期管理器、PluginHost 实现)。
|
||
- ``health/``:健康检查实现(聚合器、渠道探测、诊断导出)。
|
||
- ``config/``:配置热更新注册表。
|
||
- ``circuit_breaker/``:渠道级熔断器。
|
||
- ``outbox/``:Outbox 后台任务(恢复扫描、重试 Worker、审计清理、配对过期)。
|
||
- ``executor/``:工具与消息操作执行器。
|
||
|
||
顶层导出:
|
||
- 5 个用例服务:``InboundMessageService`` / ``AdminMessageService`` /
|
||
``ChannelControlService`` / ``PluginLifecycleService`` / ``HealthCheckService``。
|
||
- 3 条管道:``InboundPipeline`` / ``OutboundPipeline`` / ``ControlPlanePipeline``。
|
||
- 3 个上下文:``InboundContext`` / ``OutboundContext`` / ``ControlPlaneContext``。
|
||
- 管道基础设施:``Pipeline`` / ``AppStage`` / ``FailureStrategy``。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from yuxi.channels.application.context import (
|
||
ControlPlaneContext,
|
||
InboundContext,
|
||
OutboundContext,
|
||
)
|
||
from yuxi.channels.application.pipeline import AppStage, FailureStrategy, Pipeline
|
||
from yuxi.channels.application.pipeline.control_plane import ControlPlanePipeline
|
||
from yuxi.channels.application.pipeline.inbound import InboundPipeline
|
||
from yuxi.channels.application.pipeline.outbound import OutboundPipeline
|
||
from yuxi.channels.application.usecase import (
|
||
AdminMessageService,
|
||
ChannelControlService,
|
||
HealthCheckService,
|
||
InboundMessageService,
|
||
PluginLifecycleService,
|
||
)
|
||
|
||
__all__ = [
|
||
# 用例服务(5 个)
|
||
"InboundMessageService",
|
||
"AdminMessageService",
|
||
"ChannelControlService",
|
||
"PluginLifecycleService",
|
||
"HealthCheckService",
|
||
# 管道(3 条)
|
||
"InboundPipeline",
|
||
"OutboundPipeline",
|
||
"ControlPlanePipeline",
|
||
# 上下文(3 个)
|
||
"InboundContext",
|
||
"OutboundContext",
|
||
"ControlPlaneContext",
|
||
# 管道基础设施
|
||
"Pipeline",
|
||
"AppStage",
|
||
"FailureStrategy",
|
||
]
|