Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSRuntime ¶
type JSRuntime interface {
// Execute runs JavaScript code and returns the result as a string
Execute(code string) (string, error)
// ExecuteWithProps runs a cached bundle with props injected
// The bundle is compiled once and cached; only props change per request
ExecuteWithProps(bundle, propsJSON string) (string, error)
// Close releases resources (called when returning to pool)
Reset()
// Destroy permanently destroys the runtime
Destroy()
}
JSRuntime is the interface for JavaScript execution
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages a pool of JS runtimes for reuse
func (*Pool) Close ¶
func (p *Pool) Close()
Close marks the pool as closed and destroys all runtimes
func (*Pool) Execute ¶
Execute is a convenience method that gets a runtime, executes code, and returns it
func (*Pool) ExecuteWithProps ¶
ExecuteWithProps executes a cached bundle with props
type PoolConfig ¶
type PoolConfig struct {
RuntimeType RuntimeType
PoolSize int // Maximum number of runtimes to keep in pool
}
PoolConfig configures the runtime pool
type RuntimeType ¶
type RuntimeType string
RuntimeType represents the type of JavaScript runtime
const ( RuntimeQuickJS RuntimeType = "quickjs" RuntimeV8 RuntimeType = "v8" RuntimeModerncJS RuntimeType = "moderncjs" )
func DefaultRuntimeType ¶
func DefaultRuntimeType() RuntimeType
DefaultRuntimeType returns the runtime type for this build
type V8Runtime ¶
type V8Runtime struct {
// contains filtered or unexported fields
}
V8Runtime wraps V8 for pooled usage
func (*V8Runtime) ExecuteWithProps ¶
ExecuteWithProps runs a cached bundle with props injected The bundle is compiled once as UnboundScript and cached Only the small props script is compiled each request