feat: 实现Redis集成协议并重构项目控制台
refactor(backend): 重构后端服务以支持Redis协议 feat(backend): 添加Redis客户端和服务模块 feat(backend): 实现命令和日志路由处理Redis交互 refactor(frontend): 重构前端状态管理和组件结构 feat(frontend): 实现基于Redis的日志和命令功能 docs: 添加Redis集成协议文档 chore: 更新ESLint配置和依赖
This commit is contained in:
13
openspec/changes/update-redis-protocol/proposal.md
Normal file
13
openspec/changes/update-redis-protocol/proposal.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Change: Update Redis Integration Protocol
|
||||
|
||||
## Why
|
||||
需要为“BLS Project Console ↔ 其他业务项目”的 Redis 交互约定一个稳定、可机器生成的协议,明确每个接入项目必须写入的状态与控制台信息,以及必须读取的控制指令队列。
|
||||
|
||||
## What Changes
|
||||
- 统一 Redis Key 命名规则:每个项目写 2 个 key、读 1 个 key
|
||||
- 明确每个 key 的 Redis 数据类型(STRING/LIST)与 value 格式(枚举值/JSON)
|
||||
- 对齐 logging / command / redis-connection 三个 capability 的 requirements(以便实现端可依据 spec 开发)
|
||||
|
||||
## Impact
|
||||
- Affected specs: specs/redis-connection/spec.md, specs/logging/spec.md, specs/command/spec.md
|
||||
- Affected code (planned): src/backend/routes/, src/backend/services/, src/frontend/components/
|
||||
15
openspec/changes/update-redis-protocol/specs/command/spec.md
Normal file
15
openspec/changes/update-redis-protocol/specs/command/spec.md
Normal file
@@ -0,0 +1,15 @@
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Command Sending to Redis
|
||||
The system SHALL send commands to a per-target Redis key.
|
||||
|
||||
#### Scenario: Console enqueues a command for a target project
|
||||
- **WHEN** the user sends a command from the console
|
||||
- **THEN** the backend SHALL append a JSON message to Redis LIST key `${targetProjectName}_控制`
|
||||
- **AND** the JSON message SHALL represent the command payload (an object)
|
||||
|
||||
#### Scenario: Target project consumes a command
|
||||
- **WHEN** a target project listens for commands
|
||||
- **THEN** it SHALL consume messages from `${projectName}_控制` as JSON objects
|
||||
- **AND** it SHOULD use Redis LIST queue semantics (producer `RPUSH`, consumer `BLPOP`)
|
||||
- **AND** if `BLPOP` is not available, it MAY use a `LRANGE` + `LTRIM` compatibility pattern
|
||||
14
openspec/changes/update-redis-protocol/specs/logging/spec.md
Normal file
14
openspec/changes/update-redis-protocol/specs/logging/spec.md
Normal file
@@ -0,0 +1,14 @@
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Log Reading from Redis
|
||||
The system SHALL read log records from per-project Redis keys.
|
||||
|
||||
#### Scenario: External project writes console logs
|
||||
- **WHEN** an external project emits debug/error information
|
||||
- **THEN** it SHALL append entries to a Redis LIST key named `${projectName}_项目控制台`
|
||||
- **AND** each entry SHALL be a JSON string representing a log record
|
||||
|
||||
#### Scenario: Server reads project console logs
|
||||
- **WHEN** the server is configured to show a given project
|
||||
- **THEN** it SHALL read entries from `${projectName}_项目控制台`
|
||||
- **AND** it SHALL present them in the console UI with timestamp, level and message
|
||||
@@ -0,0 +1,9 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Per-Project Status Key
|
||||
The system SHALL standardize a per-project Redis status key for connected projects.
|
||||
|
||||
#### Scenario: External project writes status
|
||||
- **WHEN** an external project integrates with this console
|
||||
- **THEN** it SHALL write a Redis STRING key named `${projectName}_项目状态`
|
||||
- **AND** the value SHALL be one of: `在线`, `离线`, `故障`, `报错`
|
||||
13
openspec/changes/update-redis-protocol/tasks.md
Normal file
13
openspec/changes/update-redis-protocol/tasks.md
Normal file
@@ -0,0 +1,13 @@
|
||||
## 1. Documentation
|
||||
- [x] 1.1 Add Redis integration protocol doc for external projects
|
||||
- [ ] 1.2 Link doc location from README (optional)
|
||||
|
||||
## 2. Backend
|
||||
- [x] 2.1 Add Redis client config + connection helper
|
||||
- [x] 2.2 Implement command enqueue: write `${targetProjectName}_控制` LIST with JSON payload
|
||||
- [x] 2.3 Implement log fetch/stream: read `${projectName}_项目控制台` LIST (and status `${projectName}_项目状态` STRING when needed)
|
||||
|
||||
## 3. Frontend
|
||||
- [x] 3.1 Wire selected project name into Console (targetProjectName)
|
||||
- [x] 3.2 Replace simulated command send with API call to backend
|
||||
- [x] 3.3 Replace simulated logs with backend-provided logs (polling or SSE)
|
||||
@@ -62,6 +62,7 @@ BLS Project Console是一个前后端分离的Node.js项目,用于从Redis队
|
||||
- **可靠性**: Redis连接需要具备重连机制,确保系统稳定运行
|
||||
- **安全性**: API接口需要适当的访问控制
|
||||
- **可扩展性**: 系统设计应支持未来功能扩展
|
||||
- **开发约束**: 一旦遇到 lint/build/tooling 失败(例如 ESLint 配置错误),必须优先修复并恢复可用的开发工作流,再继续功能开发
|
||||
|
||||
## External Dependencies
|
||||
- **Redis**: 用于存储日志记录和控制台指令的消息队列服务
|
||||
|
||||
Reference in New Issue
Block a user