pluginkit

package module
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package pluginkit provides compile-time plugin infrastructure: a lifecycle contract, a plugin host, and route guarding for plugin namespaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Protect

func Protect(handler http.Handler, publicPaths []string, wrap func(http.Handler) http.Handler) http.Handler

Protect wraps a plugin handler in the caller-supplied middleware and serves the plugin's declared public paths untouched (exact match, per PublicPathProvider).

Types

type Host

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

Host starts and stops a fixed set of plugins.

func NewHost

func NewHost(plugins ...Plugin) *Host

NewHost returns a Host managing plugins. It panics when two plugins share an ID.

func (*Host) Migrate

func (h *Host) Migrate(ctx context.Context) error

Migrate applies the schema of every Migrator plugin in registration order, stopping at the first failure.

func (*Host) PublicPaths

func (h *Host) PublicPaths() map[string][]string

PublicPaths returns the session-exempt paths of every PublicPathProvider plugin, keyed by plugin ID.

func (*Host) Routes

func (h *Host) Routes() map[string]http.Handler

Routes returns the HTTP handler of every RouteProvider plugin, keyed by plugin ID.

func (*Host) Seed

func (h *Host) Seed(ctx context.Context) error

Seed asks every Seeder plugin to fill its schema in registration order, stopping at the first failure.

func (*Host) Start

func (h *Host) Start(ctx context.Context, stopGrace time.Duration) error

Start migrates and starts every plugin in order, stopping the started ones within stopGrace when one fails.

func (*Host) Stop

func (h *Host) Stop(ctx context.Context) error

Stop stops every plugin in reverse registration order, continuing past failures and returning them joined.

type Migrator

type Migrator interface {
	Migrate(ctx context.Context) error
}

Migrator is implemented by plugins that own database schema, which the host migrates before starting any plugin.

type Plugin

type Plugin interface {
	ID() string
	Start(ctx context.Context) error
	// Stop releases what the plugin holds, returning by the time ctx ends, whether or not Start ran.
	Stop(ctx context.Context) error
}

Plugin is an independently addable unit of functionality with a managed lifecycle.

type PublicPathProvider

type PublicPathProvider interface {
	PublicPaths() []string
}

PublicPathProvider is implemented by plugins declaring namespace-relative paths that must stay reachable without a session. Paths match exactly, for every HTTP method, and all else stays protected.

type RouteProvider

type RouteProvider interface {
	Routes() http.Handler
}

RouteProvider is implemented by plugins that expose HTTP endpoints under their own namespace.

type Seeder

type Seeder interface {
	Seed(ctx context.Context) error
}

Seeder is implemented by plugins that can fill their own schema with development data, which the host asks for outside the start path.

Directories

Path Synopsis
graphwire module
Package wire generates an application's plugin wiring files from the plugin.json manifest of every directory under each configured plugin root.
Package wire generates an application's plugin wiring files from the plugin.json manifest of every directory under each configured plugin root.

Jump to

Keyboard shortcuts

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