lolly/internal/lua/config.go
xfy 7156bbc82f refactor(lua): 改进代码风格和文档注释
- 为 LuaEngine/LuaContext/LuaCoroutine 添加命名说明注释
- 为 Phase 常量添加文档注释
- 规范 import 排序顺序
- 处理 Write 返回值避免 lint 警告
- 修复文件末尾换行符

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 16:55:38 +08:00

45 lines
1.3 KiB
Go
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.

// Package lua 提供 Lua 脚本嵌入能力
// 采用 Server 级单 LState + 请求级临时协程架构
package lua
import (
"time"
)
// Config Lua 引擎配置
type Config struct {
// 协程配置
MaxConcurrentCoroutines int // 最大并发协程数(默认 1000
CoroutineTimeout time.Duration // 协程执行超时(默认 30s
// 字节码缓存配置
CodeCacheSize int // 缓存条目数(默认 1000
CodeCacheTTL time.Duration // 缓存过期时间(默认 1h
// 文件监控
EnableFileWatch bool // 是否启用文件变更检测(默认 true
// 执行限制
MaxExecutionTime time.Duration // 单脚本最大执行时间(默认 30s
// 安全设置
EnableOSLib bool // 是否加载 os 库(默认 false
EnableIOLib bool // 是否加载 io 库(默认 false
EnableLoadLib bool // 是否允许 load/loadfile默认 false
}
// DefaultConfig 返回默认配置
func DefaultConfig() *Config {
return &Config{
MaxConcurrentCoroutines: 1000,
CoroutineTimeout: 30 * time.Second,
CodeCacheSize: 1000,
CodeCacheTTL: time.Hour,
EnableFileWatch: true,
MaxExecutionTime: 30 * time.Second,
EnableOSLib: false,
EnableIOLib: false,
EnableLoadLib: false,
}
}