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 ¶
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.
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.