pluginkit

package module
v0.5.1 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: 4 Imported by: 0

README

pluginkit

This repository is archived. Both modules moved to the Gopherium framework, where their releases continue.

Old path New path
github.com/gopherium/pluginkit github.com/gopherium/framework/pluginkit
github.com/gopherium/pluginkit/graphwire github.com/gopherium/framework/pluginkit/graphwire

The first framework releases are pluginkit 0.6.0 and graphwire 0.4.0. Read their changelog before you move, since Host.Start now takes a stop grace. The guides live on the docs site.

Report security problems to the framework, as its security policy explains.

License

Copyright 2026 Manuel 'SirLouen' Camargo

Apache License 2.0 (LICENSE). Every file carries an SPDX-License-Identifier: Apache-2.0 header.

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) 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 added in v0.3.0

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) error

Start migrates every Migrator plugin, then starts every plugin in registration order, stopping the already-started ones in reverse order when a start 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(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 added in v0.3.0

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