v8engine

package
v0.1.14 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

NewFactory creates a new jsexecutor.JsEngineFactory for the V8 engine.

func WithRpcScript

func WithRpcScript(script string) jsexecutor.JsEngineOption

WithRpcScript provides an option to override the default RPC handling script. This allows for custom RPC logic or extending the engine's capabilities. WithRpcScript sets the RPC script for the engine. The script must not be empty.

Types

type Engine

type Engine struct {
	// Iso is the V8 Isolate, representing a single-threaded VM instance.
	// It is exposed publicly to allow for advanced custom options.
	Iso *v8go.Isolate

	// Ctx is the V8 Context, representing the execution environment.
	// It is exposed publicly to allow for advanced custom options.
	Ctx *v8go.Context

	// Option holds the engine-specific configurations.
	Option *EngineOption

	// RpcScript contains the JavaScript code for handling RPC calls.
	RpcScript string
	// contains filtered or unexported fields
}

Engine implements the jsexecutor.JsEngine interface using the V8 engine. It encapsulates a V8 Isolate and Context.

func (*Engine) Close

func (e *Engine) Close() error

Close releases all resources associated with the V8 engine.

func (*Engine) Execute

func (e *Engine) Execute(req *jsexecutor.JsRequest) (*jsexecutor.JsResponse, error)

Execute runs a JavaScript request using the RPC script.

func (*Engine) Load added in v0.1.11

func (e *Engine) Load(scripts []*jsexecutor.JsScript) error

Load loads initialization scripts in the V8 context.

type EngineOption

type EngineOption struct{}

EngineOption holds specific configurations for the V8 engine.

Jump to

Keyboard shortcuts

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