From 686b8c323943b250ec3209951d5821930318662b Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 14 Apr 2026 14:53:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(lua):=20=E8=B0=83=E6=95=B4=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=AD=97=E6=AE=B5=E9=A1=BA=E5=BA=8F=E5=B0=86=E5=8D=8F?= =?UTF-8?q?=E7=A8=8B=E6=B1=A0=E5=8F=82=E6=95=B0=E9=9B=86=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 CoroutinePoolWarmup 字段移至 CoroutineStackSize 后, 使协程相关配置字段集中在一起,便于理解和维护。 Co-Authored-By: Claude Opus 4.6 --- internal/config/config.go | 12 ++++++------ internal/lua/config.go | 12 ++++++------ internal/lua/middleware_config.go | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 52c7b28..ec09fc8 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1403,9 +1403,6 @@ type LuaGlobalSettings struct { // CodeCacheSize 字节码缓存条目数 CodeCacheSize int `yaml:"code_cache_size"` - // EnableFileWatch 启用文件变更检测 - EnableFileWatch bool `yaml:"enable_file_watch"` - // MaxExecutionTime 单脚本最大执行时间 MaxExecutionTime time.Duration `yaml:"max_execution_time"` @@ -1413,11 +1410,14 @@ type LuaGlobalSettings struct { // 较小的栈减少内存分配,适用于简单脚本 CoroutineStackSize int `yaml:"coroutine_stack_size"` - // MinimizeStackMemory 启用栈内存自动收缩以减少内存占用 - MinimizeStackMemory bool `yaml:"minimize_stack_memory"` - // CoroutinePoolWarmup 协程池预热数量,启动时预创建 CoroutinePoolWarmup int `yaml:"coroutine_pool_warmup"` + + // EnableFileWatch 启用文件变更检测 + EnableFileWatch bool `yaml:"enable_file_watch"` + + // MinimizeStackMemory 启用栈内存自动收缩以减少内存占用 + MinimizeStackMemory bool `yaml:"minimize_stack_memory"` } // StreamConfig TCP/UDP Stream 代理配置。 diff --git a/internal/lua/config.go b/internal/lua/config.go index aab52ea..1944427 100644 --- a/internal/lua/config.go +++ b/internal/lua/config.go @@ -13,13 +13,13 @@ type Config struct { CodeCacheSize int CodeCacheTTL time.Duration MaxExecutionTime time.Duration - EnableFileWatch bool - EnableOSLib bool - EnableIOLib bool - EnableLoadLib bool - CoroutineStackSize int // 协程栈大小(默认64,最大256) + CoroutineStackSize int // 协程栈大小(默认64,最大256) + CoroutinePoolWarmup int // 协程池预热数量,启动时预创建 + EnableFileWatch bool // 1 + EnableOSLib bool // 1 + EnableIOLib bool // 1 + EnableLoadLib bool // 1 MinimizeStackMemory bool // 启用栈内存自动收缩以减少内存占用 - CoroutinePoolWarmup int // 协程池预热数量,启动时预创建 } // DefaultConfig 返回默认配置 diff --git a/internal/lua/middleware_config.go b/internal/lua/middleware_config.go index afb6d2c..5ad8013 100644 --- a/internal/lua/middleware_config.go +++ b/internal/lua/middleware_config.go @@ -40,9 +40,6 @@ type GlobalLuaSettings struct { // CodeCacheSize 字节码缓存条目数 CodeCacheSize int `yaml:"code_cache_size"` - // EnableFileWatch 启用文件变更检测 - EnableFileWatch bool `yaml:"enable_file_watch"` - // MaxExecutionTime 单脚本最大执行时间 MaxExecutionTime time.Duration `yaml:"max_execution_time"` @@ -50,11 +47,14 @@ type GlobalLuaSettings struct { // 较小的栈减少内存分配,适用于简单脚本 CoroutineStackSize int `yaml:"coroutine_stack_size"` - // MinimizeStackMemory 启用栈内存自动收缩以减少内存占用 - MinimizeStackMemory bool `yaml:"minimize_stack_memory"` - // CoroutinePoolWarmup 协程池预热数量,启动时预创建 CoroutinePoolWarmup int `yaml:"coroutine_pool_warmup"` + + // EnableFileWatch 启用文件变更检测 + EnableFileWatch bool `yaml:"enable_file_watch"` + + // MinimizeStackMemory 启用栈内存自动收缩以减少内存占用 + MinimizeStackMemory bool `yaml:"minimize_stack_memory"` } // DefaultMiddlewareConfig 默认 Lua 中间件配置