runner

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package runner provides the execution interface for running functions. Supports multiple event types with type-specific responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnhanceError

func EnhanceError(err error, sourceCode string) error

EnhanceError transforms a raw Lua error into a user-friendly error message with code context and actionable suggestions.

The enhanced error includes:

  • The original error message with line number
  • Code snippet showing surrounding lines with the error line highlighted
  • A column indicator (^) when column information is available
  • Pattern-matched suggestions for common Lua errors

Returns nil if err is nil. If line number cannot be extracted from the error, only the error message and suggestion (if applicable) are included.

Types

type Dependencies

type Dependencies struct {
	Logger       logger.Logger
	KV           kv.Store
	Env          env.Store
	HTTP         internalhttp.Client
	AI           ai.Client
	AITracker    ai.Tracker
	Email        email.Client
	EmailTracker email.Tracker
	Timeout      time.Duration // Execution timeout (defaults to 5 minutes if not set)
}

Dependencies holds all the dependencies needed to run a Lua function

type LuaRuntime

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

LuaRuntime implements the engine.Runtime interface for Lua code execution.

func NewLuaRuntime

func NewLuaRuntime(cfg LuaRuntimeConfig) *LuaRuntime

NewLuaRuntime creates a new LuaRuntime with the given configuration.

func (*LuaRuntime) Execute

Execute implements the engine.Runtime interface.

type LuaRuntimeConfig

type LuaRuntimeConfig struct {
	Logger       logger.Logger
	KV           kv.Store
	Env          env.Store
	HTTP         internalhttp.Client
	AI           ai.Client
	AITracker    ai.Tracker
	Email        email.Client
	EmailTracker email.Tracker
	Timeout      time.Duration
}

LuaRuntimeConfig holds the configuration for creating a LuaRuntime.

type Request

type Request struct {
	Context *events.ExecutionContext
	Event   events.Event
	Code    string
}

Request represents a function execution request

type Response

type Response struct {
	Type events.EventType
	HTTP *events.HTTPResponse
}

Response represents the response from executing a function The actual response data depends on the event type

func Run

func Run(ctx context.Context, deps Dependencies, req Request) (Response, error)

Run executes a Lua function with the given event

Jump to

Keyboard shortcuts

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