Documentation
¶
Overview ¶
Package engine provides execution engines for running site scripts. It supports a fallback chain: QuickJS (fast, no browser) → CDP Browser (full browser).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunScript ¶
func RunScript(ctx context.Context, engines []Engine, s *script.Script, args map[string]string) (any, error)
RunScript tries each engine in order, returning the first successful result. If a result contains an "error" field (e.g. {"error":"HTTP 400"}), it is treated as a failure and the next engine is tried. If all engines fail, returns the last error.
Types ¶
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser executes scripts in a real Chrome browser via CDP.
func NewBrowser ¶
NewBrowser creates a new Browser engine backed by the given transport.
type Engine ¶
type Engine interface {
// Run executes a script with the given arguments.
Run(ctx context.Context, s *script.Script, args map[string]string) (any, error)
// Name returns the engine name for logging.
Name() string
// Close releases resources held by the engine.
Close() error
}
Engine can execute a site script with arguments and return a JSON-compatible result.
type QuickJS ¶
type QuickJS struct {
// contains filtered or unexported fields
}
QuickJS executes scripts in an embedded QuickJS runtime with a Go-backed fetch().
func NewQuickJS ¶
NewQuickJS creates a new QuickJS engine backed by the given transport.