script

package
v0.3.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const MAX_LUA_RUNNING_TIME = 2 * time.Minute

Variables

This section is empty.

Functions

This section is empty.

Types

type Message added in v0.2.0

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

type NoScriptFoundError added in v0.2.3

type NoScriptFoundError struct{}

func (*NoScriptFoundError) Error added in v0.2.3

func (e *NoScriptFoundError) Error() string

type Reply added in v0.2.1

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 added in v0.2.1

func NewErrReply(err error) *Reply

func NewReply added in v0.2.1

func NewReply() *Reply

func (*Reply) JSON added in v0.2.1

func (r *Reply) JSON() ([]byte, error)

type ScriptExecutor

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

ScriptExecutor defines the structure responsible for managing Lua script execution

func NewScriptExecutor

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

NewScriptExecutor creates a new ScriptExecutor using the provided ScriptStore

func (*ScriptExecutor) HandleMessage

func (se *ScriptExecutor) 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 (*ScriptExecutor) Stop

func (se *ScriptExecutor) Stop()

Stop gracefully shuts down the ScriptExecutor and stops watching for messages

type ScriptResult added in v0.2.5

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"`
}

Jump to

Keyboard shortcuts

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