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

executor

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	HandleMessage(context.Context, *Message, func(*Reply))
	Stop()
}

func NewLuaExecutor

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

NewLuaExecutor creates a new ScriptExecutor using the provided ScriptStore

func NewWasmExecutor

func NewWasmExecutor(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, replyFunc func(r *Reply))

HandleMessage receives a message, matches it to a Lua script, and executes the script in a new goroutine

func (*LuaExecutor) Stop

func (se *LuaExecutor) Stop()

Stop gracefully shuts down the ScriptExecutor and stops watching for messages

type Message

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

type NoScriptFoundError

type NoScriptFoundError struct{}

func (*NoScriptFoundError) Error

func (e *NoScriptFoundError) Error() string

type Reply

type Reply struct {
	Results    sync.Map
	HTML       bool                     `json:"is_html"`
	Error      string                   `json:"error,omitempty"`
	AllResults map[string]*ScriptResult `json:"results,omitempty"`
}

func NewErrReply

func NewErrReply(err error) *Reply

func NewReply

func NewReply() *Reply

func (*Reply) Bytes

func (r *Reply) Bytes() []byte

Bytes: Append each of the replies to eachother and return it

func (*Reply) JSON

func (r *Reply) JSON() ([]byte, 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"`
}

type WasmExecutor

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

func (*WasmExecutor) HandleMessage

func (we *WasmExecutor) HandleMessage(ctx context.Context, msg *Message, replyFunc func(r *Reply))

func (*WasmExecutor) Stop

func (we *WasmExecutor) Stop()

Jump to

Keyboard shortcuts

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