plugin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package plugin provides host-side utilities for working with sqld plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Annotate

func Annotate(sql, sourceFile string, schema *pluginv1.AnnotationSchema) ([]*irv1.AnnotationValue, error)

Annotate scans sql for SQL comments that match entries in schema, and returns a slice of typed AnnotationValues in document order. It never panics; malformed comments are skipped or parsed best-effort.

Supported comment styles are controlled by schema.CommentStyles:

  • "--" line comments (default when CommentStyles is empty)
  • "/* */" block comments

Every produced AnnotationValue has Source.StartOffset/EndOffset set to the byte range of the comment within sql (StartOffset = index of "--" or "/*", EndOffset = index just past end-of-line or "*/").

Types

type Runner

type Runner interface {
	// GetInfo retrieves metadata about the plugin (name, version, capabilities).
	GetInfo(ctx context.Context) (*pluginv1.GetInfoResponse, error)

	// Generate invokes the plugin's code-generation logic.
	Generate(ctx context.Context, req *pluginv1.GenerateRequest) (*pluginv1.GenerateResponse, error)

	// Close releases any resources held by the runner.
	Close() error
}

Runner drives a single generator plugin regardless of transport.

func Open

func Open(pc config.PluginConfig) (Runner, error)

Open constructs a Runner for the plugin described by pc. Transport is selected based on which of pc.Binary/Command/Wasm is non-empty:

  • Binary → stdio-framed protobuf over an exec'd process (binaryRunner).
  • Command → same as Binary but the field name differs.
  • Wasm → WASI module via wazero (wasmRunner).

Jump to

Keyboard shortcuts

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