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

warpc

package
v0.153.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShutdown = fmt.Errorf("dispatcher is shutting down")

Functions

This section is empty.

Types

type Binary

type Binary struct {
	// The name of the binary.
	// For 	quickjs, this must match the instance import name, "javy_quickjs_provider_v2".
	// For the main module, we only use this for caching.
	Name string

	// THe wasm binary.
	Data []byte
}

Binary represents a WebAssembly binary.

type CompileModuleContext

type CompileModuleContext struct {
	Opts    Options
	Runtime wazero.Runtime
}

type CompiledModule

type CompiledModule struct {
	// Runtime (e.g. QuickJS) may be nil if not needed (e.g. embedded in Module).
	Runtime wazero.CompiledModule

	// If Runtime is not nil, this should be the name of the instance.
	RuntimeName string

	// The main module to instantiate.
	// This will be insantiated multiple times in a pool,
	// so it does not need a name.
	Module wazero.CompiledModule
}

type Dispatcher

type Dispatcher[Q, R any] interface {
	Execute(ctx context.Context, q Message[Q]) (Message[R], error)
	Close() error
}

func Start

func Start[Q, R any](opts Options) (Dispatcher[Q, R], error)

Start creates a new dispatcher pool.

type Dispatchers

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

Dispatchers holds all the dispatchers for the warpc package.

func AllDispatchers

func AllDispatchers(katexOpts Options) *Dispatchers

AllDispatchers creates all the dispatchers for the warpc package. Note that the individual dispatchers are started lazily. Remember to call Close on the returned Dispatchers when done.

func (*Dispatchers) Close

func (d *Dispatchers) Close() error

func (*Dispatchers) Katex

type Header struct {
	// Major version of the protocol.
	Version uint16 `json:"version"`

	// Unique ID for the request.
	// Note that this only needs to be unique within the current request set time window.
	ID uint32 `json:"id"`

	// Set in the response if there was an error.
	Err string `json:"err"`

	// Warnings is a list of warnings that may be returned in the response.
	Warnings []string `json:"warnings,omitempty"`
}

Header is in both the request and response.

type KatexInput

type KatexInput struct {
	Expression string       `json:"expression"`
	Options    KatexOptions `json:"options"`
}

See https://katex.org/docs/options.html

type KatexOptions

type KatexOptions struct {
	// html, mathml (default), htmlAndMathml
	Output string `json:"output"`

	// If true, display math in display mode, false in inline mode.
	DisplayMode bool `json:"displayMode"`

	// Render \tags on the left side instead of the right.
	Leqno bool `json:"leqno"`

	// If true,  render flush left with a 2em left margin.
	Fleqn bool `json:"fleqn"`

	// The color used for typesetting errors.
	// A color string given in the format "#XXX" or "#XXXXXX"
	ErrorColor string `json:"errorColor"`

	// A collection of custom macros.
	Macros map[string]string `json:"macros,omitempty"`

	// Specifies a minimum thickness, in ems, for fraction lines.
	MinRuleThickness float64 `json:"minRuleThickness"`

	// If true, KaTeX will throw a ParseError when it encounters an unsupported command.
	ThrowOnError bool `json:"throwOnError"`

	// Controls how KaTeX handles LaTeX features that offer convenience but
	// aren't officially supported, one of error (default), ignore, or warn.
	//
	//  - error: Throws an error when convenient, unsupported LaTeX features
	//    are encountered.
	//  - ignore: Allows convenient, unsupported LaTeX features without any
	//    feedback.
	//  - warn: Emits a warning when convenient, unsupported LaTeX features are
	//    encountered.
	//
	// The "newLineInDisplayMode" error code, which flags the use of \\
	// or \newline in display mode outside an array or tabular environment, is
	// intentionally designed not to throw an error, despite this behavior
	// being questionable.
	Strict string `json:"strict"`
}

KatexOptions defines the options for the KaTeX rendering. See https://katex.org/docs/options.html

type KatexOutput

type KatexOutput struct {
	Output string `json:"output"`
}

type Message

type Message[T any] struct {
	Header Header `json:"header"`
	Data   T      `json:"data"`
}

func (Message[T]) GetID

func (m Message[T]) GetID() uint32

type Options

type Options struct {
	Ctx context.Context

	Infof func(format string, v ...any)

	Warnf func(format string, v ...any)

	// E.g. quickjs wasm. May be omitted if not needed.
	Runtime Binary

	// The main module to instantiate.
	Main Binary

	CompilationCacheDir string
	PoolSize            int

	// Memory limit in MiB.
	Memory int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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