luaEngine

package
v0.35.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const LoadLuaLibs = "load_lua_libs"

LoadLuaLibs If config.Properties sets this key, then it means to load the built-in lua third-party tool library, otherwise do not load

Variables

View Source
var Preloader = &preloader{}

Functions

func BytesToLuaTable added in v0.32.0

func BytesToLuaTable(L *lua.LState, data []byte) *lua.LTable

BytesToLuaTable converts byte array to Lua table where each element is a byte value (0-255) Lua arrays are 1-indexed, so byte at index 0 in Go becomes index 1 in Lua

func GoToLua

func GoToLua(L *lua.LState, v interface{}) lua.LValue

GoToLua converts a Go value to a lua.LValue

func IsLuaArray added in v0.32.0

func IsLuaArray(table *lua.LTable) bool

IsLuaArray checks if a lua table is array-like

func LTableToMap

func LTableToMap(table *lua.LTable) map[string]interface{}

LTableToMap converts a lua.LTable to a map[string]interface{}

func LTableToStringMap

func LTableToStringMap(table *lua.LTable) map[string]string

LTableToStringMap converts a lua.LTable to a map[string]string

func LuaTableToBytes added in v0.32.0

func LuaTableToBytes(table *lua.LTable) []byte

LuaTableToBytes converts Lua table (byte array) back to []byte Assumes the Lua table contains numeric values representing bytes (0-255)

func LuaTableToSlice added in v0.32.0

func LuaTableToSlice(table *lua.LTable) []interface{}

LuaTableToSlice converts a lua table to a slice

func LuaToGo

func LuaToGo(value lua.LValue) interface{}

LuaToGo converts a lua.LValue to an interface{}

func MapToLTable

func MapToLTable(L *lua.LState, m map[string]interface{}) *lua.LTable

MapToLTable converts a map to a lua.LTable

func PrepareMessageData added in v0.32.0

func PrepareMessageData(L *lua.LState, msg types.RuleMsg) lua.LValue

PrepareMessageData prepares message data for Lua processing based on the message data type This function handles the conversion from Go message data to appropriate Lua types: - JSON: Converts to Lua table (object or array) - BINARY: Converts to Lua table representing byte array - Others: Keeps as Lua string

func RegisterContextMethods added in v0.31.0

func RegisterContextMethods(L *lua.LState, config types.Config, chainId string)

RegisterContextMethods 将全局缓存和链缓存功能注册到 Lua 状态中。 GlobalCache: 直接绑定到引擎的全局缓存。 ChainCache: 如果 config.Cache 和 chainId 不为空,则会根据 chainId 创建一个命名空间缓存实例,并将其作为 Lua 全局对象 ChainCache。否则 ChainCache 将为 nil。

func SliceToLTable added in v0.32.0

func SliceToLTable(L *lua.LState, slice interface{}) *lua.LTable

SliceToLTable converts a slice to a lua.LTable

func StringMapToLTable

func StringMapToLTable(L *lua.LState, m map[string]string) *lua.LTable

StringMapToLTable converts a map to a lua.LTable

func ValidateLua

func ValidateLua(script string) error

ValidateLua 验证脚本是否正确

Types

type LStatePool

type LStatePool struct {
	// contains filtered or unexported fields
}

func NewFileLStatePool

func NewFileLStatePool(config types.Config, path string, configuration types.Configuration) *LStatePool

func NewStringLStatePool

func NewStringLStatePool(config types.Config, script string, configuration types.Configuration) *LStatePool

func (*LStatePool) Get

func (pl *LStatePool) Get() *lua.LState

func (*LStatePool) New

func (pl *LStatePool) New() *lua.LState

func (*LStatePool) Put

func (pl *LStatePool) Put(L *lua.LState)

func (*LStatePool) Shutdown

func (pl *LStatePool) Shutdown()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL