新增完整的 channels 限界上下文模块,包含契约层、领域核心层、应用服务、管道编排、插件体系、基础设施组合根等全层级代码,新增飞书与微信 iLink 渠道插件基础结构,补充各类 DTO、端口协议与领域服务实现。
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
"""IdentityResolverAdapter:实现 IdentityResolverPort,默认降级实现。
|
||
|
||
- 默认降级实现,由插件可覆盖
|
||
- resolve 返回 None(触发降级至 DB 查询)
|
||
- getConfidence 返回 0.0
|
||
|
||
依赖边界:只依赖 yuxi.channels.contract(端口 + DTO)。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from yuxi.channels.contract.dtos.identity import (
|
||
IdentityResolveCmd,
|
||
IdentityResolveResult,
|
||
)
|
||
from yuxi.channels.contract.ports.driven.identity_resolver_port import IdentityResolverPort
|
||
|
||
|
||
class IdentityResolverAdapter(IdentityResolverPort):
|
||
"""身份解析被驱动适配器(默认降级实现)。
|
||
|
||
默认实现不接入外部身份源,``resolve`` 返回 ``None`` 触发降级至 DB
|
||
查询,``getConfidence`` 返回 ``0.0``。实际身份解析逻辑由插件注册时
|
||
注入。
|
||
"""
|
||
|
||
async def resolve(self, cmd: IdentityResolveCmd) -> IdentityResolveResult | None:
|
||
"""解析身份(默认降级,返回 None)。
|
||
|
||
默认不接入外部身份源,返回 None 触发降级至 DB 查询。
|
||
实际解析逻辑由插件覆盖。
|
||
|
||
Args:
|
||
cmd: 身份解析命令,携带渠道类型、对端 ID 与账户 ID。
|
||
|
||
Returns:
|
||
None(默认降级)。
|
||
"""
|
||
return None
|
||
|
||
async def getConfidence(self, identity_id: str) -> float:
|
||
"""查询身份置信度(默认降级,返回 0.0)。
|
||
|
||
默认返回 ``0.0``,实际置信度由插件覆盖。
|
||
|
||
Args:
|
||
identity_id: 统一身份 ID。
|
||
|
||
Returns:
|
||
0.0(默认降级)。
|
||
"""
|
||
return 0.0
|