plugin

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package plugin provides the type-keyed capability registry used by the GoModularAuth plugin runtime.

A plugin MODULE is the installable component (organizations.New()). A plugin CAPABILITY is the type the application consumes (plugins.Organization). Modules register capabilities in the Registry; applications retrieve them with auth.Get[T]().

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when no module provides the requested capability.
	ErrNotFound = errors.New("plugin: capability not registered")
	// ErrDuplicate is returned when a module ID or capability is registered twice.
	ErrDuplicate = errors.New("plugin: duplicate registration")
)

Functions

func Lookup added in v1.3.0

func Lookup[T any](r *Registry) (T, error)

Lookup returns the implementation of capability T.

func Provide added in v1.3.0

func Provide[T any](r *Registry, module string, value T) error

Provide registers value as the implementation of capability T on behalf of module. T is usually an interface type exported by the plugin.

Types

type Registry added in v1.3.0

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

Registry stores modules by ID and capabilities by their static type. It is safe for concurrent use.

func NewRegistry added in v1.3.0

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) AddModule added in v1.3.0

func (r *Registry) AddModule(id string) error

AddModule records a module ID. IDs must be unique.

func (*Registry) HasModule added in v1.3.0

func (r *Registry) HasModule(id string) bool

HasModule reports whether a module ID has been registered.

func (*Registry) Modules added in v1.3.0

func (r *Registry) Modules() []string

Modules returns a list of all registered module IDs.

Jump to

Keyboard shortcuts

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