plugin

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plugin implements compile-time plugins, settings and migration metadata.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSettings = errors.New("invalid plugin settings")

ErrInvalidSettings reports a client-supplied settings value that does not match its schema.

View Source
var ErrPluginLifecycleActive = errors.New("plugin lifecycle is active")

ErrPluginLifecycleActive reports an attempt to change the active plugin set while an application is running.

View Source
var ErrPluginNotFound = errors.New("plugin not found")

ErrPluginNotFound reports an operation on an unknown plugin.

Functions

This section is empty.

Types

type AdminModuleProvider added in v2.0.1

type AdminModuleProvider interface {
	RegisterAdmin(resources.Registrar) error
}

AdminModuleProvider registers executable Admin API modules and handlers.

type AdminOperationProvider added in v2.0.1

type AdminOperationProvider interface {
	AdminOperations() []operations.Registration
}

AdminOperationProvider supplies typed Admin operations. The server assigns the trusted provider namespace from the plugin registry entry.

type AdminPermissionProvider added in v2.0.1

type AdminPermissionProvider interface {
	AdminPermissions() []auth.Permission
}

AdminPermissionProvider declares permissions used by a plugin's Admin API. Role assignment remains server-owned.

type AdminProvider

type AdminProvider interface {
	AdminResources() []AdminResource
}

AdminProvider supplies declarative Admin API resources.

type AdminResource

type AdminResource struct {
	Name        string
	Title       string
	Description string
	Model       any
	Permissions []string
}

type AdminUIOperationProvider added in v2.0.1

type AdminUIOperationProvider interface {
	AdminUIOperations() adminui.OperationExtension
}

AdminUIOperationProvider supplies the optional, separately versioned declarative overlay for Operations-backed Admin UI actions.

type AdminUIProvider added in v2.0.1

type AdminUIProvider interface {
	AdminUI() adminui.Descriptor
}

AdminUIProvider supplies a declarative Admin UI descriptor. The server assigns the provider namespace from the plugin registry entry.

type App

type App interface{}

App is the runtime value passed to plugins during initialization. Plugins may type-assert it to the application contracts they require.

type Configurable

type Configurable interface {
	DefaultSettings() map[string]any
}

Configurable supplies default plugin settings.

type Entry

type Entry struct {
	Plugin         Plugin
	Manifest       Manifest
	Enabled        bool
	Settings       map[string]any
	SettingsSchema SettingsSchema
	AdminResources []AdminResource
	Migrations     []Migration
}

type FileMigrationStore

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

func NewFileMigrationStore

func NewFileMigrationStore(path string) *FileMigrationStore

func (*FileMigrationStore) IsApplied

func (s *FileMigrationStore) IsApplied(ctx context.Context, namespace, migrationID string) (bool, error)

func (*FileMigrationStore) ListApplied

func (s *FileMigrationStore) ListApplied(ctx context.Context, namespace string) (map[string]time.Time, error)

func (*FileMigrationStore) MarkApplied

func (s *FileMigrationStore) MarkApplied(ctx context.Context, namespace, migrationID string, appliedAt time.Time) error

func (*FileMigrationStore) UnmarkApplied

func (s *FileMigrationStore) UnmarkApplied(ctx context.Context, namespace, migrationID string) error

type FileSettingsStore

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

func NewFileSettingsStore

func NewFileSettingsStore(path string) *FileSettingsStore

func (*FileSettingsStore) Load

func (s *FileSettingsStore) Load(ctx context.Context, pluginName string) (map[string]any, error)

func (*FileSettingsStore) Save

func (s *FileSettingsStore) Save(ctx context.Context, pluginName string, settings map[string]any) error

type Manifest

type Manifest struct {
	Name        string
	Version     string
	Description string
	Author      string
}

Manifest contains public plugin metadata.

type ManifestProvider

type ManifestProvider interface {
	Manifest() Manifest
}

ManifestProvider supplies extended plugin metadata.

type MemoryMigrationStore

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

func NewMemoryMigrationStore

func NewMemoryMigrationStore() *MemoryMigrationStore

func (*MemoryMigrationStore) IsApplied

func (s *MemoryMigrationStore) IsApplied(ctx context.Context, pluginName, migrationID string) (bool, error)

func (*MemoryMigrationStore) ListApplied

func (s *MemoryMigrationStore) ListApplied(ctx context.Context, namespace string) (map[string]time.Time, error)

func (*MemoryMigrationStore) MarkApplied

func (s *MemoryMigrationStore) MarkApplied(ctx context.Context, pluginName, migrationID string, appliedAt time.Time) error

func (*MemoryMigrationStore) UnmarkApplied

func (s *MemoryMigrationStore) UnmarkApplied(ctx context.Context, pluginName, migrationID string) error

type Migratable

type Migratable interface {
	Migrations() []Migration
}

Migratable supplies plugin migrations.

type Migration

type Migration struct {
	ID   string
	Name string
	Up   func(ctx context.Context) error
	Down func(ctx context.Context) error
}

Migration is an ordered, uniquely identified plugin schema or data change. Up and Down must be idempotent: state persistence cannot be atomic with arbitrary external side effects if a process stops between the two.

type MigrationCoordinator added in v2.0.2

type MigrationCoordinator interface {
	WithMigrationLock(ctx context.Context, fn func() error) error
}

MigrationCoordinator serializes a complete migration run across processes.

type MigrationReport

type MigrationReport struct {
	Applied int
	Skipped int
}

type MigrationStateInspector

type MigrationStateInspector interface {
	ListApplied(ctx context.Context, namespace string) (map[string]time.Time, error)
}

type MigrationStateMutator

type MigrationStateMutator interface {
	UnmarkApplied(ctx context.Context, namespace, migrationID string) error
}

type MigrationStateStore

type MigrationStateStore interface {
	IsApplied(ctx context.Context, pluginName, migrationID string) (bool, error)
	MarkApplied(ctx context.Context, pluginName, migrationID string, appliedAt time.Time) error
}

type Plugin

type Plugin interface {
	Name() string
	Version() string
	Init(app App) error
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
}

Plugin defines the lifecycle required by the runtime registry.

type Registry

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

Registry owns plugin registration, state, settings and metadata.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty plugin registry.

func (*Registry) Active

func (r *Registry) Active() []Plugin

func (*Registry) AdminResources

func (r *Registry) AdminResources(name string) ([]AdminResource, bool)

func (*Registry) All

func (r *Registry) All() []Plugin

func (*Registry) ApplyMigrations

func (r *Registry) ApplyMigrations(ctx context.Context, store MigrationStateStore) (MigrationReport, error)

func (*Registry) BeginRuntime added in v2.0.1

func (r *Registry) BeginRuntime() []Plugin

BeginRuntime freezes the active plugin set and returns its snapshot.

func (*Registry) Disable

func (r *Registry) Disable(name string) error

func (*Registry) Enable

func (r *Registry) Enable(name string) error

func (*Registry) EndRuntime added in v2.0.1

func (r *Registry) EndRuntime()

EndRuntime permits startup-time plugin selection again.

func (*Registry) Entries

func (r *Registry) Entries() []Entry

func (*Registry) LoadSettings

func (r *Registry) LoadSettings(ctx context.Context) error

func (*Registry) Manifests

func (r *Registry) Manifests() []Manifest

func (*Registry) Register

func (r *Registry) Register(p Plugin) error

Register adds a plugin and captures its optional capabilities.

func (*Registry) SetSetting

func (r *Registry) SetSetting(name, key string, value any) error

func (*Registry) SetSettingsStore

func (r *Registry) SetSettingsStore(store SettingsStateStore)

func (*Registry) Setting

func (r *Registry) Setting(name, key string) (any, bool)

func (*Registry) Settings

func (r *Registry) Settings(name string) (map[string]any, bool)

func (*Registry) SettingsSchema

func (r *Registry) SettingsSchema(name string) (SettingsSchema, bool)

func (*Registry) UpdateSettings

func (r *Registry) UpdateSettings(name string, updates map[string]any) error

func (*Registry) UpdateSettingsContext added in v2.0.1

func (r *Registry) UpdateSettingsContext(ctx context.Context, name string, updates map[string]any) error

UpdateSettingsContext validates and durably stores settings before making them visible to readers. Updates are serialized to prevent lost writes.

type SessionMigrationStore

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

func NewSessionMigrationStore

func NewSessionMigrationStore(repo storage.SessionRepository) *SessionMigrationStore

func (*SessionMigrationStore) IsApplied

func (s *SessionMigrationStore) IsApplied(ctx context.Context, pluginName, migrationID string) (bool, error)

func (*SessionMigrationStore) ListApplied

func (s *SessionMigrationStore) ListApplied(ctx context.Context, namespace string) (map[string]time.Time, error)

func (*SessionMigrationStore) MarkApplied

func (s *SessionMigrationStore) MarkApplied(ctx context.Context, pluginName, migrationID string, appliedAt time.Time) error

func (*SessionMigrationStore) UnmarkApplied

func (s *SessionMigrationStore) UnmarkApplied(ctx context.Context, pluginName, migrationID string) error

func (*SessionMigrationStore) WithMigrationLock added in v2.0.2

func (s *SessionMigrationStore) WithMigrationLock(ctx context.Context, fn func() error) error

type SessionSettingsStore

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

func NewSessionSettingsStore

func NewSessionSettingsStore(repo storage.SessionRepository) *SessionSettingsStore

func (*SessionSettingsStore) Load

func (s *SessionSettingsStore) Load(ctx context.Context, pluginName string) (map[string]any, error)

func (*SessionSettingsStore) Save

func (s *SessionSettingsStore) Save(ctx context.Context, pluginName string, settings map[string]any) error

type SettingField

type SettingField struct {
	Key         string
	Type        string
	Title       string
	Description string
	Default     any
	Required    bool
	Sensitive   bool
}

type SettingsSchema

type SettingsSchema struct {
	Fields []SettingField
}

type SettingsSchemaProvider

type SettingsSchemaProvider interface {
	SettingsSchema() SettingsSchema
}

SettingsSchemaProvider describes accepted plugin settings.

type SettingsStateStore

type SettingsStateStore interface {
	Load(ctx context.Context, pluginName string) (map[string]any, error)
	Save(ctx context.Context, pluginName string, settings map[string]any) error
}

Jump to

Keyboard shortcuts

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