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

javascript

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package javascript evaluates Spectre response comparator scripts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Evaluator

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

Evaluator owns the JavaScript runtime for one response comparison. It is confined to its caller because Sobek runtime access is not synchronized.

func (*Evaluator) Close

func (e *Evaluator) Close()

Close releases the evaluator's context watcher.

func (*Evaluator) CompareField

func (e *Evaluator) CompareField(
	target string,
	reference any,
	referencePresent bool,
	candidate any,
	candidatePresent bool,
) (matched bool, err error)

CompareField invokes the comparator registered for a protobuf field.

func (*Evaluator) CompareMessage

func (e *Evaluator) CompareMessage(
	target string,
	reference any,
	referencePresent bool,
	candidate any,
	candidatePresent bool,
) (matched bool, err error)

CompareMessage invokes the comparator registered for a protobuf message.

func (*Evaluator) CompareRPC

func (e *Evaluator) CompareRPC(
	target string,
	reference any,
	referencePresent bool,
	candidate any,
	candidatePresent bool,
) (matched bool, err error)

CompareRPC invokes the comparator registered for an RPC method.

type Program

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

Program is an immutable script shared by all response comparisons. It retains no runtime-local callback state.

func NewProgram

func NewProgram(ctx context.Context, name, source string) (*Program, error)

NewProgram parses and links a script, then evaluates it once to validate registrations.

func (*Program) Fields

func (p *Program) Fields() []string

Fields returns the protobuf fields declared by the script.

func (*Program) Messages

func (p *Program) Messages() []string

Messages returns the protobuf messages declared by the script.

func (*Program) NewEvaluator

func (p *Program) NewEvaluator(ctx context.Context) (*Evaluator, error)

NewEvaluator creates an isolated evaluator for one response comparison. Re-evaluation must reproduce the registrations used to build the schema plan.

func (*Program) RPCs

func (p *Program) RPCs() []string

RPCs returns the RPC methods declared by the script.

Jump to

Keyboard shortcuts

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