plugins

package
v0.9.1 Latest Latest
Warning

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

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

Documentation

Overview

Package plugins provides a small, transport-agnostic plugin framework modeled on the Endpoint Picker (EPP) plugin model (sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins). It defines the base Plugin identity, a configuration-driven factory Registry, and a Handle that gives plugins access to shared, host-provided context.

This package is intentionally free of Kubernetes/controller-runtime dependencies: the EPP-specific RunnablePlugin and pod-listing concerns are not replicated, since they have no analog for in-process request plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustRegister

func MustRegister(pluginType string, factory FactoryFunc)

MustRegister is like Register but panics on error. It is intended for use in plugin package init() functions, where a duplicate registration is a programming error that should fail at startup.

func Register

func Register(pluginType string, factory FactoryFunc) error

Register registers a plugin factory under the given type. It returns an error if the type is already registered, so duplicate registrations fail loudly rather than silently overwriting.

func Unregister

func Unregister(pluginType string)

Unregister removes the factory registered under the given type, if any. It is primarily intended to let tests clean up registrations they make so the registry stays isolated between test runs.

Types

type FactoryFunc

type FactoryFunc func(name string, parameters json.RawMessage, handle Handle) (Plugin, error)

FactoryFunc instantiates a plugin from its instance name, raw JSON parameters (as found in configuration), and a Handle to host-provided context. The signature mirrors EPP so plugin authoring is familiar across the projects.

func Lookup

func Lookup(pluginType string) (FactoryFunc, bool)

Lookup returns the factory registered under the given type, if any.

type Handle

type Handle interface {
	// Context returns a context the plugins can use, if they need one.
	Context() context.Context

	HandlePlugins
}

Handle provides plugins a set of standard data and tools to work with. It is a trimmed, Kubernetes-free analog of EPP's Handle: it carries a context and the set of instantiated plugins, but omits EPP's pod-listing concerns.

func NewHandle

func NewHandle(ctx context.Context) Handle

NewHandle returns a Handle backed by the given context and an empty plugin set.

type HandlePlugins

type HandlePlugins interface {
	// Plugin returns the named plugin instance, or nil if none is registered.
	Plugin(name string) Plugin

	// AddPlugin adds a plugin to the set of known plugin instances.
	AddPlugin(name string, plugin Plugin)
}

HandlePlugins defines a set of APIs to work with instantiated plugins.

type Plugin

type Plugin interface {
	// TypedName returns the type and name tuple of this plugin instance.
	TypedName() TypedName
}

Plugin defines the base interface every plugin must satisfy. Typed capability interfaces (e.g. a request body-transform) embed this interface and add their own methods, mirroring the EPP plugin model.

type TypedName

type TypedName struct {
	// Type is the registered plugin type (the key under which a FactoryFunc is
	// registered in the Registry).
	Type string
	// Name is the instance name of a plugin, unique within a configuration.
	Name string
}

TypedName is a utility struct providing a type and a name to plugins.

func (TypedName) String

func (tn TypedName) String() string

String returns the type and name rendered as "<name>/<type>".

Jump to

Keyboard shortcuts

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