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

plugin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package plugin defines the transport-neutral hook surfaces and the ordered registry. Products wrap Registry and add their own typed hooks (schema/API, compile, request); the catalog and inflection hooks live here because they only depend on introspect and inflect.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatalogHook

type CatalogHook interface {
	TransformCatalog(ctx context.Context, c *introspect.Catalog) error
}

CatalogHook mutates or filters the introspected catalog before API building (e.g. hide tables, rename via comments).

type InflectionHook

type InflectionHook interface {
	Inflect(kind inflect.Kind, in inflect.Input, next inflect.Next) string
}

InflectionHook controls every generated name. Call next to get the downstream (ultimately default) name; return your own to override.

type Plugin

type Plugin interface {
	Name() string
	Priority() int
}

Plugin is the base interface: identity plus default priority. Lower priority runs earlier (outermost in middleware chains); ties break by registration order.

type Registry

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

Registry holds plugins in deterministic order.

func NewRegistry

func NewRegistry(plugins ...Plugin) *Registry

NewRegistry builds a registry with the given plugins added in order.

func (*Registry) Add

func (r *Registry) Add(p Plugin)

Add registers a plugin, keeping the list sorted by (priority, insertion).

func (*Registry) All

func (r *Registry) All() []Plugin

All returns plugins in execution order.

func (*Registry) Enabled

func (r *Registry) Enabled(disabled map[string]bool) []Plugin

Enabled returns plugins in execution order, excluding disabled names.

func (*Registry) Inflector

func (r *Registry) Inflector(disabled map[string]bool, base inflect.Next) inflect.Next

Inflector composes all InflectionHooks into a single naming function with base (the product's default inflector) as the innermost link.

func (*Registry) TransformCatalog

func (r *Registry) TransformCatalog(ctx context.Context, disabled map[string]bool, c *introspect.Catalog) error

TransformCatalog runs all CatalogHooks in order.

Jump to

Keyboard shortcuts

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