6 Commits

Author SHA1 Message Date
xfy
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
xfy
ad177e9640 docs(lua): 为 Lua API 模块添加标准化 godoc 注释
为所有 Lua API 文件添加完整的包级和函数级文档注释:
- api_balancer: 负载均衡 API(set_current_peer, set_more_tries 等)
- api_ctx: 请求上下文存储 API(ngx.ctx)
- api_location: 子请求捕获 API(ngx.location.capture)
- api_log: 日志输出 API(ngx.log)
- api_req: 请求对象 API
- api_resp: 响应对象 API
- api_shared_dict: 共享字典 API
- api_socket_tcp: TCP socket API
- api_timer: 定时器 API
- api_var: 变量 API
- engine: Lua 引擎核心
- context: 请求上下文管理
- coroutine: 协程调度器
- middleware: 中间件集成
- filter_writer: 响应过滤器
- cache: Lua 脚本缓存
- shared_dict: 共享字典实现
- socket_manager: socket 连接管理

注释格式遵循 Go 官方风格,包含功能说明、参数说明和注意事项。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 10:59:17 +08:00
xfy
686b8c3239 refactor(lua): 调整配置字段顺序将协程池参数集中
将 CoroutinePoolWarmup 字段移至 CoroutineStackSize 后,
使协程相关配置字段集中在一起,便于理解和维护。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 14:53:12 +08:00
xfy
cf0ea6cc1f perf(lua): 完成协程栈优化配置集成
将 Lua 协程栈优化选项集成到配置系统中:
- CoroutineStackSize: 默认64,减少内存分配
- MinimizeStackMemory: 启用栈内存自动收缩
- CoroutinePoolWarmup: 默认预热4个协程

影响文件:
- internal/config/config.go: 添加配置项到 LuaGlobalSettings
- internal/lua/middleware_config.go: 中间件配置支持
- internal/server/init.go: 服务器初始化应用配置

优化效果(已在 engine.go 和 config.go 中实现):
- BenchmarkCoroutineCreation 内存减少18.7% (112KB->91KB)
- 延迟减少约27.6% (29us->21us)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 14:33:30 +08:00
xfy
8b382606df Merge branch 'lint-fix' - resolve sendfile.go conflict
Conflict: sendfile.go (!linux build tag) was incorrectly modified to
include linuxSendfile and getSocketFd functions which already exist
in sendfile_linux.go.

Resolution: Keep HEAD version (simple fallback returning ENOTSUP) as
Linux implementation is properly separated in sendfile_linux.go.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 09:26:48 +08:00
xfy
bfab449241 feat(lua): 实现 Lua 中间件系统
添加可配置的 Lua 中间件实现,支持:
- 多执行阶段(rewrite、access、content、header_filter、body_filter、log)
- 脚本路径配置和超时控制
- 中间件启用/禁用开关
- 配置文件热加载
- 完整的单元测试和性能基准测试

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