Help us shape the future of Go! Take the 2026 Go Developer Survey

executor

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_LUA_RUNNING_TIME = 2 * time.Minute
	EXECUTOR_LUA_NAME    = "lua"
	EXECUTOR_WASM_NAME   = "wasm"
	EXECUTOR_PODMAN_NAME = "podman"
)

Variables

This section is empty.

Functions

func StartAllExecutors added in v0.5.0

func StartAllExecutors(ctx context.Context, scriptStore store.ScriptStore, plugins []plugins.PreloadFunc, nc *nats.Conn) map[string]Executor

func StopAllExecutors added in v0.5.0

func StopAllExecutors(executors map[string]Executor)

Types

type Executor

type Executor interface {
	HandleMessage(context.Context, *Message, *script.Script) *ScriptResult
	Stop()
}

func ExecutorByName added in v0.5.0

func ExecutorByName(name string, executors map[string]Executor) (Executor, error)

func NewLuaExecutor

func NewLuaExecutor(c context.Context, store msgstore.ScriptStore, plugins []msgplugins.PreloadFunc, nc *nats.Conn) Executor

NewLuaExecutor creates a new ScriptExecutor using the provided ScriptStore

func NewPodmanExecutor added in v0.4.1

func NewPodmanExecutor(c context.Context, store msgstore.ScriptStore) (Executor, error)

func NewWasmExecutor

func NewWasmExecutor(c context.Context, store msgstore.ScriptStore, plugins []msgplugins.PreloadFunc, nc *nats.Conn) Executor

type LuaExecutor

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

LuaExecutor defines the structure responsible for managing Lua script execution

func (*LuaExecutor) HandleMessage

func (le *LuaExecutor) HandleMessage(ctx context.Context, msg *Message, scr *script.Script) *ScriptResult

HandleMessage receives a message, matches it to a Lua script, and executes the script in a new goroutine Run the Lua script in a separate goroutine to handle the message for each script

func (*LuaExecutor) Stop

func (se *LuaExecutor) Stop()

Stop gracefully shuts down the ScriptExecutor and stops watching for messages

type Message

type Message struct {
	Async   bool   `json:"async"`
	Method  string `json:"method"`
	Payload []byte `json:"payload"`
	Raw     bool   `json:"raw"`
	Subject string `json:"subject"`
	URL     string `json:"url"`
}

type NoScriptFoundError

type NoScriptFoundError struct{}

func (*NoScriptFoundError) Error

func (e *NoScriptFoundError) Error() string

type Reply

type Reply struct {
	Results []*ScriptResult `json:"script_result"`
	HTML    bool            `json:"is_html"`
	Error   string          `json:"error,omitempty"`
}

func SpawnWorker added in v1.0.0

func SpawnWorker(ctx context.Context, workerPath string, envPath string, input WorkerInput) (*Reply, error)

type ScriptResult

type ScriptResult struct {
	Code    int               `json:"http_code"`
	Error   string            `json:"error"`
	Headers map[string]string `json:"http_headers"`
	IsHTML  bool              `json:"is_html"`
	Payload []byte            `json:"payload"`
}

func ScriptResultWithError added in v0.8.0

func ScriptResultWithError(err error) *ScriptResult

type WorkerInput added in v1.0.0

type WorkerInput struct {
	NatsURL     string                  `json:"nats_url"`
	ScriptStore *WorkerInputScriptStore `json:"script_store"`
	LuaExecutor *WorkerInputLuaExecutor `json:"lua_executor"`
	Message     *Message                `json:"messsage"`
}

type WorkerInputLuaExecutor added in v1.0.0

type WorkerInputLuaExecutor struct {
	PluginDir string `json:"plugin_dir"`
}

type WorkerInputScriptStore added in v1.0.0

type WorkerInputScriptStore struct {
	BackendName      string `json:"backend_name"`
	EtcdURL          string `json:"etcd_url"`
	ScriptDirectory  string `json:"script_directory"`
	LibraryDirectory string `json:"library_directory"`
}

type WorkerOutput added in v1.0.0

type WorkerOutput struct {
	Error error  `json:"error"`
	Reply *Reply `json:"reply"`
}

Jump to

Keyboard shortcuts

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