fengling-console/.planning/phases/01-gateway-config-management/01-CONTEXT.md

76 lines
2.2 KiB
Markdown
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.

# Phase 1: 实现 Gateway 配置管理及事件推送 - Context
**收集日期:** 2026-03-02
**状态:** Ready for planning
**来源:** Manual planning (gsd-tools not available)
**更新:** 2026-03-03 - 添加数据源决策
<domain>
## Phase Boundary
实现 Console 管理 Gateway 配置的完整能力,包括:
- Gateway 配置的 CRUD 操作(已大部实现)
- 配置变更事件推送(待实现)
- 下游 Gateway 监听配置变更并重载
**现有能力:**
- GatewayController: API 端点已实现
- GatewayService: 业务逻辑已实现
- DTOs: 数据传输对象已定义
**待实现:**
- ReloadGatewayAsync() 广播机制
- 配置变更时自动触发广播
</domain>
<decisions>
## Implementation Decisions
### 技术选型
- **广播机制**: PostgreSQL NOTIFY/LISTEN轻量方案无需额外依赖
- **备选方案**: Redis pub/sub如需多实例通信
### 数据源
- **通知服务数据库连接**: 从 EF Core DbContext 获取,而非从配置文件读取
- **实现方式**: 注入 ConsoleDbContext使用 `DbContext.Database.GetConnectionString()`
### 功能决策
- **自动广播**: 配置变更(创建/更新/删除)时自动触发广播
- **手动广播**: 提供 /api/console/gateway/reload 手动触发端点
### Claude's Discretion
- 具体的 NOTIFY 通道名称格式
- 事件 payload 结构设计
- 是否需要事件类型区分service/route/instance
</decisions>
<specifics>
## Specific Ideas
**关键文件:**
- src/Services/GatewayService.cs - ReloadGatewayAsync() 空实现需填充
- src/Controllers/GatewayController.cs - POST /reload 端点
- src/Services/ConfigNotificationService.cs - 需修改为使用 DbContext 获取连接字符串
**依赖:**
- Npgsql - PostgreSQL 通知(已通过 EF Core 引用)
- Redis可选- 如选择 Redis pub/sub
**参考实现:**
- 网关已有 PgSqlConfigChangeListener 使用 NOTIFY/LISTEN可复用
</specifics>
<deferred>
## Deferred Ideas
- K8s 服务健康检查(后续 Phase
- Redis pub/sub如果 PostgreSQL NOTIFY 方案不够用再考虑)
</deferred>
---
*Phase: 01-gateway-config-management*
*Context gathered: 2026-03-02, updated 2026-03-03*