lolly/internal/AGENTS.md
xfy 392d0b3449 docs: 新增模块 AGENTS.md 文档,更新目录索引
- 新增 http2、integration、resolver、variable 模块 AGENTS.md
- 更新 internal/AGENTS.md 目录表,补充新模块条目
- 更新 docs/prompts.md 添加 generate-config 缺失项分析提示
- 同步更新日期戳至 2026-04-09

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 13:35:29 +08:00

59 lines
2.5 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.

<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2026-04-02 | Updated: 2026-04-09 -->
# internal
## Purpose
核心业务代码目录包含服务器、配置、处理器、中间件、日志等模块。Go 的 internal 包机制确保这些代码不可被外部项目导入。
## Subdirectories
| Directory | Purpose |
|-----------|---------|
| `app/` | 应用程序入口和运行逻辑(启动、信号处理、版本信息) |
| `benchmark/` | 基准测试基础设施Mock 后端、负载生成器、回归检测) |
| `cache/` | 文件缓存模块(缓存存储、过期管理) |
| `config/` | 配置解析、验证和默认值生成 |
| `handler/` | HTTP 请求处理器路由、静态文件、Sendfile |
| `http2/` | HTTP/2 协议支持ALPN 协商、fasthttp 适配) |
| `http3/` | HTTP/3 (QUIC) 协议支持fasthttp 适配、0-RTT |
| `integration/` | 集成测试(多模块端到端协作验证) |
| `loadbalance/` | 负载均衡策略(轮询、最少连接、健康检查) |
| `logging/` | 日志系统zerolog 初始化、访问日志) |
| `middleware/` | 中间件框架(接口定义、链式组合) |
| `netutil/` | 网络工具函数(客户端 IP 提取、URL 解析) |
| `proxy/` | 反向代理模块HTTP/WebSocket 代理) |
| `resolver/` | DNS 解析器(缓存、后台刷新、域名动态解析) |
| `server/` | HTTP 服务器核心、虚拟主机、热升级、状态监控 |
| `ssl/` | SSL/TLS 管理证书加载、OCSP Stapling |
| `stream/` | TCP/UDP Stream 代理模块 |
| `variable/` | 变量系统nginx 风格变量展开、日志格式模板) |
## For AI Agents
### Working In This Directory
- 所有包使用 `rua.plus/lolly/internal/{package}` 导入路径
- 各子包有独立职责,遵循 Go 包设计原则
- 添加新功能时应参考 `docs/plan.md` 确定所属模块
- 测试文件与源文件同目录,使用 `_test.go` 后缀
### Testing Requirements
- 每个包应有对应的测试文件
- 运行测试:`go test ./internal/...`
- 测试覆盖率目标 >80%
### Common Patterns
- 使用 fasthttp 的 `RequestHandler` 函数签名处理请求
- 配置结构体使用 `yaml` 标签
- 中间件通过 `Chain.Apply()` 逆序包装
- 服务器通过 `fasthttp.Server` 配置超时和连接限制
## Dependencies
### External
- `github.com/valyala/fasthttp` - HTTP 服务器框架
- `github.com/fasthttp/router` - 路由器
- `github.com/rs/zerolog` - 日志库
- `gopkg.in/yaml.v3` - YAML 解析
<!-- MANUAL: -->