Documentation
ΒΆ
Index ΒΆ
- func IsErrorCode(err error, code ErrorCode) bool
- func WithContext(err error, key string, value interface{}) error
- type CLIConfig
- type CLIConfigOptions
- type Config
- func (c *Config) Call(funcName string, args ...interface{}) ([]interface{}, error)
- func (c *Config) ClearStack()
- func (c *Config) Close()
- func (c *Config) ComposeFunctions(name string, funcs ...string) error
- func (c *Config) DoFile(filename string) error
- func (c *Config) DoString(script string) error
- func (c *Config) Eval(expr string) (interface{}, error)
- func (c *Config) GenerateDocs(v interface{}, gen DocGenerator) (string, error)
- func (c *Config) Get(ctx context.Context, name string, target interface{}) error
- func (c *Config) GetGlobal(name string, target interface{}) error
- func (c *Config) GetRawLuaValue(pos int) (lua.LValue, error)
- func (c *Config) GetStackSize() int
- func (c *Config) LoadDirectory(dir string) error
- func (c *Config) LoadFile(ctx context.Context, filename string) error
- func (c *Config) NewCLIConfig(opts CLIConfigOptions) *CLIConfig
- func (c *Config) NewEnvManager(configDir string) *EnvManager
- func (c *Config) NewPluginManager(pcfg PluginConfig) *PluginManager
- func (c *Config) NewWatcher(wcfg WatcherConfig) (*ConfigWatcher, error)
- func (c *Config) PeekValue(pos int) (interface{}, error)
- func (c *Config) PopValue() (interface{}, error)
- func (c *Config) ProcessTemplate(filename string, tcfg TemplateConfig) error
- func (c *Config) PushLuaValue(v lua.LValue)
- func (c *Config) PushValue(v interface{}) error
- func (c *Config) RegisterConstants(constants map[string]interface{}) error
- func (c *Config) RegisterFunction(ctx context.Context, name string, fn interface{}) error
- func (c *Config) RegisterFunctionTable(ctx context.Context, name string, funcs map[string]interface{}) error
- func (c *Config) RegisterHook(hookType HookType, hook Hook)
- func (c *Config) RegisterLuaFunction(name string, fn func(*lua.LState) int) error
- func (c *Config) RegisterLuaFunctionString(name string, luaCode string) error
- func (c *Config) RegisterLuaFunctionWithOptions(name string, fn func(*lua.LState) int, opts FunctionOptions) error
- func (c *Config) RegisterType(ctx context.Context, name string, typeStruct interface{}, ...) error
- func (c *Config) SetGlobal(name string, value interface{}) error
- type ConfigWatcher
- type DocGenerator
- type EnvManager
- type Environment
- type Error
- type ErrorCode
- type EventHandler
- type FunctionMetadata
- type FunctionOptions
- type Generator
- func (g *Generator) Array(values ...interface{}) *Generator
- func (g *Generator) Comment(text string) *Generator
- func (g *Generator) EndFunction() *Generator
- func (g *Generator) EndTable() *Generator
- func (g *Generator) Field(name string, value interface{}) *Generator
- func (g *Generator) Function(name string, params ...string) *Generator
- func (g *Generator) Raw(code string) *Generator
- func (g *Generator) Reset()
- func (g *Generator) String() string
- func (g *Generator) Table(name string) *Generator
- type Hook
- type HookEvent
- type HookType
- type LuaError
- type LuaFunction
- type LuaStackTrace
- type Middleware
- type Option
- type ParamMetadata
- type Plugin
- type PluginAPI
- type PluginConfig
- type PluginManager
- func (pm *PluginManager) CallPluginFunction(ctx context.Context, pluginName, funcName string, args ...interface{}) (interface{}, error)
- func (pm *PluginManager) EmitEvent(ctx context.Context, event string, data interface{}) error
- func (pm *PluginManager) GetPlugin(name string) (*Plugin, bool)
- func (pm *PluginManager) LoadPlugins(ctx context.Context, dir string) error
- func (pm *PluginManager) RegisterEventHandler(event string, handler EventHandler)
- type ReturnMetadata
- type Sandbox
- type SchemaValidator
- func (sv *SchemaValidator) AddCustomValidator(field string, validator func(interface{}) error)
- func (sv *SchemaValidator) AddNestedValidator(field string, validator *SchemaValidator)
- func (sv *SchemaValidator) AddPattern(field, pattern string) error
- func (sv *SchemaValidator) AddRange(field string, min, max float64)
- func (sv *SchemaValidator) Validate(cfg interface{}) error
- type TemplateConfig
- type TypeConverter
- type WatcherConfig
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func IsErrorCode ΒΆ added in v0.2.1
IsErrorCode checks if an error is a Lugo error with a specific code
func WithContext ΒΆ added in v0.2.1
WithContext adds context information to a Lugo error
Types ΒΆ
type CLIConfig ΒΆ
type CLIConfig struct {
// contains filtered or unexported fields
}
CLIConfig represents CLI-specific configuration
func (*CLIConfig) LoadPlugins ΒΆ
LoadPlugins loads all plugins from the plugin directory
type CLIConfigOptions ΒΆ
CLIConfigOptions holds options for CLI configuration
type Config ΒΆ
Config represents the configuration manager
func (*Config) ClearStack ΒΆ added in v0.2.1
func (c *Config) ClearStack()
ClearStack removes all values from the Lua stack.
func (*Config) ComposeFunctions ΒΆ added in v0.2.1
ComposeFunctions creates a new function that chains multiple functions together
func (*Config) GenerateDocs ΒΆ
func (c *Config) GenerateDocs(v interface{}, gen DocGenerator) (string, error)
func (*Config) GetRawLuaValue ΒΆ added in v0.2.1
GetRawLuaValue retrieves the raw lua.LValue at a given stack position. pos = 1 means the top of the stack. Use caution with indexing.
func (*Config) GetStackSize ΒΆ added in v0.2.1
GetStackSize returns the number of values currently on the Lua stack.
func (*Config) LoadDirectory ΒΆ
LoadDirectory loads all .lua files from a directory
func (*Config) NewCLIConfig ΒΆ
func (c *Config) NewCLIConfig(opts CLIConfigOptions) *CLIConfig
NewCLIConfig creates a new CLI configuration
func (*Config) NewEnvManager ΒΆ
func (c *Config) NewEnvManager(configDir string) *EnvManager
NewEnvManager creates a new environment manager
func (*Config) NewPluginManager ΒΆ
func (c *Config) NewPluginManager(pcfg PluginConfig) *PluginManager
NewPluginManager creates a new plugin manager
func (*Config) NewWatcher ΒΆ
func (c *Config) NewWatcher(wcfg WatcherConfig) (*ConfigWatcher, error)
NewWatcher creates a new configuration watcher
func (*Config) PeekValue ΒΆ added in v0.2.1
PeekValue returns the value at the given stack position (1-based index from the top) without removing it. pos = 1 means the top of the stack, pos = 2 means one below the top, and so on. Returns an error if pos is out of range.
func (*Config) PopValue ΒΆ added in v0.2.1
PopValue pops a value from the top of the Lua stack and converts it to a Go value. Returns an error if the conversion fails.
func (*Config) ProcessTemplate ΒΆ
func (c *Config) ProcessTemplate(filename string, tcfg TemplateConfig) error
ProcessTemplate processes a Lua configuration file as a template
func (*Config) PushLuaValue ΒΆ added in v0.2.1
PushLuaValue pushes a raw lua.LValue onto the stack without conversion.
func (*Config) PushValue ΒΆ added in v0.2.1
PushValue pushes a Go value onto the Lua stack, converting it to a Lua value.
func (*Config) RegisterConstants ΒΆ
RegisterConstants registers multiple constants at once
func (*Config) RegisterFunction ΒΆ
RegisterFunction registers a Go function in the Lua environment with middlewares
func (*Config) RegisterFunctionTable ΒΆ added in v0.2.1
func (c *Config) RegisterFunctionTable(ctx context.Context, name string, funcs map[string]interface{}) error
RegisterFunctionTable registers multiple functions in a table with context
func (*Config) RegisterHook ΒΆ
RegisterHook registers a hook for a specific point
func (*Config) RegisterLuaFunction ΒΆ added in v0.2.1
RegisterLuaFunction registers a basic Lua function
func (*Config) RegisterLuaFunctionString ΒΆ added in v0.2.1
RegisterLuaFunctionString registers a Lua function from a string
func (*Config) RegisterLuaFunctionWithOptions ΒΆ added in v0.2.1
func (c *Config) RegisterLuaFunctionWithOptions(name string, fn func(*lua.LState) int, opts FunctionOptions) error
RegisterLuaFunctionWithOptions registers a Lua function with advanced options
type ConfigWatcher ΒΆ
type ConfigWatcher struct {
// contains filtered or unexported fields
}
ConfigWatcher watches for configuration changes and reloads automatically
func (*ConfigWatcher) AddPath ΒΆ
func (w *ConfigWatcher) AddPath(path string) error
AddPath adds a path to watch
func (*ConfigWatcher) Close ΒΆ
func (w *ConfigWatcher) Close() error
Close stops watching for changes
func (*ConfigWatcher) RemovePath ΒΆ
func (w *ConfigWatcher) RemovePath(path string) error
RemovePath removes a path from watching
type DocGenerator ΒΆ
type EnvManager ΒΆ
type EnvManager struct {
// contains filtered or unexported fields
}
EnvManager manages different configuration environments
func (*EnvManager) ActivateEnvironment ΒΆ
func (em *EnvManager) ActivateEnvironment(name string) error
ActivateEnvironment activates a specific environment
func (*EnvManager) GetActiveEnvironment ΒΆ
func (em *EnvManager) GetActiveEnvironment() string
GetActiveEnvironment returns the currently active environment
func (*EnvManager) RegisterEnvironment ΒΆ
func (em *EnvManager) RegisterEnvironment(env *Environment) error
RegisterEnvironment registers a new environment
type Environment ΒΆ
type Environment struct {
// Name of the environment
Name string
// Base configuration that applies to all environments
BaseConfig string
// Environment-specific configuration
EnvConfig string
// Environment variables prefix for this environment
EnvPrefix string
// Additional configuration paths
IncludePaths []string
}
Environment represents a configuration environment (e.g., dev, staging, prod)
type Error ΒΆ
type Error struct {
Code ErrorCode
Message string
Cause error
Context map[string]interface{} // Additional context for debugging
Location string // File/line information
}
type EventHandler ΒΆ
EventHandler represents a function that handles plugin events
type FunctionMetadata ΒΆ added in v0.2.1
type FunctionMetadata struct {
Description string // Function description
Author string // Function author
Version string // Function version
Deprecated bool // Whether the function is deprecated
Tags []string // Function tags for categorization
Params []ParamMetadata // Parameter descriptions
Returns []ReturnMetadata // Return value descriptions
Examples []string // Usage examples
Middleware []string // Applied middleware names
}
FunctionMetadata contains information about a registered function
type FunctionOptions ΒΆ added in v0.2.1
type FunctionOptions struct {
Metadata *FunctionMetadata
Namespace string // Function namespace (e.g., "http.client")
Aliases []string // Alternative names for the function
Middleware []string // Middleware to apply
BeforeCall func(*lua.LState) error
AfterCall func(*lua.LState, error)
}
FunctionOptions configures a function registration
type Generator ΒΆ
type Generator struct {
// contains filtered or unexported fields
}
Generator provides a fluent API for generating Lua code
func (*Generator) EndFunction ΒΆ
EndFunction closes a function declaration
type HookEvent ΒΆ
type HookEvent struct {
Type HookType
Name string
Args []interface{}
Result interface{}
Error error
Elapsed time.Duration
}
HookEvent contains information about the hook execution
type LuaError ΒΆ added in v0.2.1
type LuaError struct {
BaseError *Error // Renamed from Error to BaseError to avoid naming conflict
Stack []LuaStackTrace
}
LuaError represents a Lua-specific error with stack trace
func NewLuaError ΒΆ added in v0.2.1
NewLuaError creates a new LuaError with stack trace from the current Lua state
func WrapLuaError ΒΆ added in v0.2.1
WrapLuaError wraps a Lua runtime error with stack trace
type LuaFunction ΒΆ
LuaFunction represents a function that can be called from Lua
type LuaStackTrace ΒΆ added in v0.2.1
type LuaStackTrace struct {
Source string // Source file or chunk name
Line int // Line number
Function string // Function name
}
LuaStackTrace represents a Lua stack frame
type Middleware ΒΆ
type Middleware func(next LuaFunction) LuaFunction
Middleware represents a function that can modify behavior
type Option ΒΆ
type Option func(*Config)
Option represents a configuration option
func WithMiddleware ΒΆ
func WithMiddleware(middleware Middleware) Option
WithMiddleware adds middleware
type ParamMetadata ΒΆ added in v0.2.1
type ParamMetadata struct {
Name string
Type string
Description string
Optional bool
Default interface{}
}
ParamMetadata describes a function parameter
type Plugin ΒΆ
type Plugin struct {
Name string
Version string
Description string
Path string
Exports map[string]interface{}
State *lua.LState
}
Plugin represents a loaded plugin
type PluginAPI ΒΆ
type PluginAPI interface {
// RegisterFunction registers a function that can be called from Lua
RegisterFunction(name string, fn interface{}) error
// RegisterHook registers a hook that will be called at specific points
RegisterHook(hookType HookType, hook Hook) error
// GetConfig returns the current configuration
GetConfig() *Config
// EmitEvent emits an event that other plugins can listen to
EmitEvent(name string, data interface{}) error
}
PluginAPI represents the interface that plugins can use to interact with the host application
type PluginConfig ΒΆ
type PluginConfig struct {
// Directory containing plugins
PluginDir string
// Plugin-specific sandbox settings
Sandbox *Sandbox
// Custom API implementation
API PluginAPI
// Allowed plugin types (e.g., "lua", "so")
AllowedTypes []string
// Plugin metadata requirements
RequiredMetadata []string
}
PluginConfig holds configuration for plugin loading
type PluginManager ΒΆ
type PluginManager struct {
// contains filtered or unexported fields
}
PluginManager handles plugin loading and lifecycle
func (*PluginManager) CallPluginFunction ΒΆ
func (pm *PluginManager) CallPluginFunction(ctx context.Context, pluginName, funcName string, args ...interface{}) (interface{}, error)
CallPluginFunction calls an exported plugin function
func (*PluginManager) EmitEvent ΒΆ
func (pm *PluginManager) EmitEvent(ctx context.Context, event string, data interface{}) error
EmitEvent emits an event to all registered handlers
func (*PluginManager) GetPlugin ΒΆ
func (pm *PluginManager) GetPlugin(name string) (*Plugin, bool)
GetPlugin returns a loaded plugin by name
func (*PluginManager) LoadPlugins ΒΆ
func (pm *PluginManager) LoadPlugins(ctx context.Context, dir string) error
LoadPlugins loads all plugins from the configured directory
func (*PluginManager) RegisterEventHandler ΒΆ
func (pm *PluginManager) RegisterEventHandler(event string, handler EventHandler)
RegisterEventHandler registers a handler for plugin events
type ReturnMetadata ΒΆ added in v0.2.1
ReturnMetadata describes a function return value
type Sandbox ΒΆ
type Sandbox struct {
EnableFileIO bool
EnableNetworking bool
EnableSyscalls bool
MaxMemory uint64 // in bytes
MaxExecutionTime time.Duration
AllowedPaths []string
BlockedPaths []string
}
Sandbox provides security restrictions
type SchemaValidator ΒΆ
type SchemaValidator struct {
// Required fields
Required []string
// Pattern matching for string fields
Patterns map[string]*regexp.Regexp
// Range validation for numeric fields
Ranges map[string]struct {
Min, Max float64
}
// Custom validation functions
CustomValidators map[string]func(interface{}) error
// Nested validators for complex types
Nested map[string]*SchemaValidator
}
SchemaValidator defines validation rules for configuration
func NewSchemaValidator ΒΆ
func NewSchemaValidator() *SchemaValidator
NewSchemaValidator creates a new schema validator
func (*SchemaValidator) AddCustomValidator ΒΆ
func (sv *SchemaValidator) AddCustomValidator(field string, validator func(interface{}) error)
AddCustomValidator adds a custom validation function for a field
func (*SchemaValidator) AddNestedValidator ΒΆ
func (sv *SchemaValidator) AddNestedValidator(field string, validator *SchemaValidator)
AddNestedValidator adds a validator for nested structures
func (*SchemaValidator) AddPattern ΒΆ
func (sv *SchemaValidator) AddPattern(field, pattern string) error
AddPattern adds a regex pattern validation for a field
func (*SchemaValidator) AddRange ΒΆ
func (sv *SchemaValidator) AddRange(field string, min, max float64)
AddRange adds numeric range validation for a field
func (*SchemaValidator) Validate ΒΆ
func (sv *SchemaValidator) Validate(cfg interface{}) error
Validate validates a configuration against the schema
type TemplateConfig ΒΆ
type TemplateConfig struct {
Variables map[string]interface{}
Functions template.FuncMap
LeftDelim string
RightDelim string
}
TemplateConfig holds configuration for template processing
type TypeConverter ΒΆ added in v0.2.1
type TypeConverter struct{}
TypeConverter provides methods for safe type conversion
func (*TypeConverter) ToBool ΒΆ added in v0.2.1
func (tc *TypeConverter) ToBool(v interface{}) (bool, error)
ToBool converts any supported value to bool
func (*TypeConverter) ToFloat ΒΆ added in v0.2.1
func (tc *TypeConverter) ToFloat(v interface{}) (float64, error)
ToFloat converts any supported value to float64
func (*TypeConverter) ToInt ΒΆ added in v0.2.1
func (tc *TypeConverter) ToInt(v interface{}) (int64, error)
ToInt converts any supported value to int64
func (*TypeConverter) ToString ΒΆ added in v0.2.1
func (tc *TypeConverter) ToString(v interface{}) (string, error)
ToString converts any supported value to string
type WatcherConfig ΒΆ
type WatcherConfig struct {
// Paths to watch for changes
Paths []string
// How often to poll for changes (for non-inotify systems)
PollInterval time.Duration
// Debounce period to avoid multiple reloads
DebounceInterval time.Duration
// Callback function when configuration is reloaded
OnReload func(error)
}
WatcherConfig contains settings for the configuration watcher
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
advanced
command
|
|
|
basic
command
|
|
|
middleware
command
|
|
|
templates
command
|
|
|
validation
command
|
|
|
watcher
command
|