lolly/internal/AGENTS.md
xfy 2688ed6a9c docs: 更新 AGENTS.md 文档,新增 benchmark/netutil/scripts 目录
- 根目录新增 scripts/ 和 .github/ 目录说明
- internal 新增 benchmark/ 和 netutil/ 目录说明
- middleware 新增 bodylimit/ 和 errorintercept/ 目录说明
- 更新日期为 2026-04-07

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:51:31 +08:00

55 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.

<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2026-04-02 | Updated: 2026-04-07 -->
# internal
## Purpose
核心业务代码目录包含服务器、配置、处理器、中间件、日志等模块。Go 的 internal 包机制确保这些代码不可被外部项目导入。
## Subdirectories
| Directory | Purpose |
|-----------|---------|
| `app/` | 应用程序入口和运行逻辑(启动、信号处理、版本信息) |
| `benchmark/` | 基准测试基础设施Mock 后端、负载生成器、回归检测) |
| `cache/` | 文件缓存模块(缓存存储、过期管理) |
| `config/` | 配置解析、验证和默认值生成 |
| `handler/` | HTTP 请求处理器路由、静态文件、Sendfile |
| `http3/` | HTTP/3 (QUIC) 协议支持fasthttp 适配、0-RTT |
| `loadbalance/` | 负载均衡策略(轮询、最少连接、健康检查) |
| `logging/` | 日志系统zerolog 初始化、访问日志) |
| `middleware/` | 中间件框架(接口定义、链式组合) |
| `netutil/` | 网络工具函数(客户端 IP 提取、URL 解析) |
| `proxy/` | 反向代理模块HTTP/WebSocket 代理) |
| `server/` | HTTP 服务器核心、虚拟主机、热升级、状态监控 |
| `ssl/` | SSL/TLS 管理证书加载、OCSP Stapling |
| `stream/` | TCP/UDP Stream 代理模块 |
## 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: -->