|
|
041bc97578
|
refactor: remove unused code identified by staticcheck
|
2026-06-03 17:46:58 +08:00 |
|
|
|
2734b04d8f
|
refactor: remove 16.8k lines of dead code across all internal packages
- Delete unused files: tempfile subsystem, matcher variants, server/internal
- Remove 200+ unused functions across proxy, ssl, lua, http2/3, stream, variable
- Fix proxy test type errors (backgroundRefresh ctx→Request)
- Move bench/tools mock backend into internal/testutil
- Remove corresponding test functions for all deleted code
|
2026-06-03 16:15:43 +08:00 |
|
|
|
91f954936e
|
refactor(server,middleware): 提取常量提高代码可读性
- ratelimit: 使用 accessUnknown 常量替代硬编码字符串
- testutil: 提取 testListenAddr 常量
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
2026-04-22 10:41:48 +08:00 |
|
|
|
d5b4509014
|
refactor(config,server): 移除 Config.Server 字段,完善 servers 多服务器配置
- 移除 Config.Server 单服务器字段,统一使用 Servers 列表
- 为 ServerConfig 添加 Default 标记支持虚拟主机默认主机
- 重命名 GetDefaultServer 为 GetDefaultServerFromList
- 更新验证逻辑确保 servers 列表必填
- 更新默认配置生成和测试适配
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
2026-04-15 13:32:36 +08:00 |
|
|
|
f04f804834
|
refactor(server): 移除废弃的 Stop 方法,更新测试使用 StopWithTimeout
移除 deprecated Stop() 方法,测试代码改用 StopWithTimeout。
testutil.go 更新为支持 servers 配置格式。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
2026-04-15 12:48:49 +08:00 |
|
|
|
fd4e164ae6
|
refactor(security): 滑动窗口限流器使用分段锁优化并发性能
将单一 counters map + 全局 mutex 改为 16 buckets 分段锁结构:
- 新增 limiterBucket 结构体,每个桶独立持有 RW 锁和计数器 map
- 使用 FNV-1a 哈希算法将键均匀分布到 16 个桶中
- 各方法修改为按 bucket 分发操作:
- Allow() / allowApproximate() / allowPrecise()
- Reset() / ResetAll() / Cleanup()
- GetStats() / GetCount()
收益:
- 并发场景下锁竞争降低约 94% (16 个桶并行)
- 基准测试显示并行 Allow 操作约 89ns/op
测试验证:
- go test -race 通过并发安全测试
- 基准测试显示吞吐提升
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
2026-04-14 14:26:01 +08:00 |
|
|
|
9144dcbb06
|
refactor(server): 提取初始化逻辑到独立函数
- 将 Start() 中的 goroutine pool 初始化提取为 initGoroutinePool()
- 将 file cache 初始化提取为 initFileCache()
- 将 Lua engine 初始化提取为 initLuaEngine()
- 将 error page manager 初始化提取为 initErrorPageManager()
- 添加 init.go 存放提取的初始化函数
- 添加 init_test.go 测试初始化函数
- 添加 testutil.go 提供测试 mock 和工具
- 添加 lua_integration_test.go Lua 中间件集成测试
- 添加 start_integration_test.go Start() 集成测试
- 添加 server_test.go nil tlsManager 测试
- 添加 lua/mock_engine.go Lua 引擎 mock 实现
- 添加 lua/api_balancer_test.go Lua balancer API 测试
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
2026-04-13 17:38:49 +08:00 |
|