interface{} to any

This commit is contained in:
Sky Johnson 2025-03-06 06:13:53 -06:00
parent df56b0eedf
commit e95babaa25
4 changed files with 11 additions and 8 deletions

3
.gitignore vendored
View File

@ -21,3 +21,6 @@
# Go workspace file
go.work
# Test directories
routes/
static/

View File

@ -2,13 +2,13 @@ package workers
// JobResult represents the result of a Lua script execution
type JobResult struct {
Value interface{} // Return value from Lua
Value any // Return value from Lua
Error error // Error if any
}
// job represents a Lua script execution request
type job struct {
Bytecode []byte // Compiled LuaJIT bytecode
Params map[string]interface{} // Parameters to pass to the script
Params map[string]any // Parameters to pass to the script
Result chan<- JobResult // Channel to send result back
}

View File

@ -42,7 +42,7 @@ func NewPool(numWorkers int) (*Pool, error) {
}
// SubmitWithContext sends a job to the worker pool with context
func (p *Pool) SubmitWithContext(ctx context.Context, bytecode []byte, params map[string]interface{}) (interface{}, error) {
func (p *Pool) SubmitWithContext(ctx context.Context, bytecode []byte, params map[string]any) (any, error) {
if !p.isRunning.Load() {
return nil, ErrPoolClosed
}

View File

@ -103,7 +103,7 @@ func (w *worker) resetState() {
}
// setParams sets job parameters as a global 'params' table
func (w *worker) setParams(params map[string]interface{}) error {
func (w *worker) setParams(params map[string]any) error {
// Create new table for params
w.state.NewTable()
@ -157,6 +157,6 @@ func (w *worker) executeJob(j job) JobResult {
}
// Submit sends a job to the worker pool
func (p *Pool) Submit(bytecode []byte, params map[string]interface{}) (interface{}, error) {
func (p *Pool) Submit(bytecode []byte, params map[string]any) (any, error) {
return p.SubmitWithContext(context.Background(), bytecode, params)
}