plugins

package
v0.0.0-...-8dab71c Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RebuildNotice

func RebuildNotice(dir string) string

RebuildNotice returns a one-line warning for an operator who has just updated Joro, or "" when no plugins are installed.

A plugin is only loadable by the exact toolchain that built the host, so replacing the binary invalidates every installed .so — silently, since the plugin dir is untouched by an update. Sharing isPluginFile with the loader is what keeps the notice and the thing it warns about counting the same files.

Types

type Manager

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

Manager loads, categorizes, and manages the lifecycle of plugins.

func NewManager

func NewManager(pluginDir string, broadcast chan<- any) *Manager

NewManager creates a plugin manager that loads plugins from pluginDir.

func (*Manager) ApplyProjectStates

func (m *Manager) ApplyProjectStates(states map[string][]byte) []string

ApplyProjectStates is the ProjectStatefulPlugin analogue of ApplyUserStates.

func (*Manager) ApplyUserStates

func (m *Manager) ApplyUserStates(states map[string][]byte) []string

ApplyUserStates calls ImportUserState on each loaded UserStatefulPlugin whose name appears in states. Returns names that did not match a loaded UserStatefulPlugin so callers can preserve those blobs across round-trips.

func (*Manager) Dashboard

func (m *Manager) Dashboard() sdk.DashboardProvider

Dashboard returns the loaded dashboard plugin, or nil.

func (*Manager) ExecProviders

func (m *Manager) ExecProviders() map[string]sdk.ExecProvider

ExecProviders returns the loaded execution providers.

func (*Manager) ExportProjectStates

func (m *Manager) ExportProjectStates() map[string][]byte

ExportProjectStates is the ProjectStatefulPlugin analogue of ExportUserStates.

func (*Manager) ExportUserStates

func (m *Manager) ExportUserStates() map[string][]byte

ExportUserStates walks every loaded plugin and returns state bytes for those that implement sdk.UserStatefulPlugin. Plugins whose ExportUserState panics or errors are skipped with a log line; the returned map only contains successful exports.

func (*Manager) Features

func (m *Manager) Features() map[string]sdk.TabProvider

Features returns the loaded plugin features (sub-tabs).

func (*Manager) GraphData

func (m *Manager) GraphData(ctx context.Context) map[string]sdk.GraphInfo

GraphData collects network graph data from all connected ExecProviders that implement GraphProvider. Returns a map keyed by provider name.

func (*Manager) HasPlugins

func (m *Manager) HasPlugins() bool

HasPlugins returns true if any plugins are loaded.

func (*Manager) InteractProviders

func (m *Manager) InteractProviders() map[string]sdk.InteractProvider

InteractProviders returns the loaded Interact-tab OOB plugins.

func (*Manager) List

func (m *Manager) List() []PluginInfo

List returns info about all loaded plugins.

func (*Manager) MarkRemoved

func (m *Manager) MarkRemoved(filename string) (restartRequired bool)

MarkRemoved records that a plugin's file has been deleted from disk, and reports whether a restart is needed to finish the job.

A plugin that loaded is still running: Go cannot unload one, so its code, routes and hooks stay live and the row stays visible as "removed" until a restart. A file that never loaded has nothing to unload, so its row simply goes away and no restart is required.

func (*Manager) PluginDataDir

func (m *Manager) PluginDataDir(name string) string

PluginDataDir returns the per-plugin data directory handed to a plugin as sdk.PluginContext.DataDir. Both the Start path that creates it and the delete path that removes it resolve it here, so a plugin's data cannot be created in one place and looked for in another. Keyed on the manifest name, not the filename, which is why a caller deleting a plugin must resolve the name from PluginInfo before the file is gone.

func (*Manager) PluginDir

func (m *Manager) PluginDir() string

PluginDir returns the directory where plugin .so/.dylib files are stored.

func (*Manager) ProxyHooks

func (m *Manager) ProxyHooks() []sdk.ProxyHook

ProxyHooks returns the loaded proxy hooks in load order.

func (*Manager) RunRequestHook

func (m *Manager) RunRequestHook(ctx context.Context, info sdk.RequestInfo, rawReq []byte) ([]byte, error)

RunRequestHook chains all proxy hooks' OnRequest methods. Returns the (possibly modified) raw request, or nil to drop.

func (*Manager) RunResponseHook

func (m *Manager) RunResponseHook(ctx context.Context, info sdk.RequestInfo, rawResp []byte) ([]byte, error)

RunResponseHook chains all proxy hooks' OnResponse methods.

func (*Manager) Shutdown

func (m *Manager) Shutdown()

Shutdown calls Shutdown() on each loaded plugin with panic recovery.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start loads all plugins from the plugin directory, categorizes them by type, and calls Init() on each. Errors during loading or init are logged but do not prevent other plugins from loading.

func (*Manager) StartDisabled

func (m *Manager) StartDisabled() error

StartDisabled is Start with the loading left out, for --no-plugins.

It still lists what is installed, as rows no plugin code was run to produce. Booting with plugins off is how an operator recovers from a plugin that prevents booting at all, so the list is the point: an empty one would hide the very file the flag exists to delete, and the delete endpoint works from a row.

func (*Manager) TabProviders

func (m *Manager) TabProviders() map[string]sdk.TabProvider

TabProviders returns the loaded top-level tab plugins.

type PluginInfo

type PluginInfo struct {
	Name     string         `json:"name"`
	Version  string         `json:"version"`
	Desc     string         `json:"description"`
	Type     sdk.PluginType `json:"type"`
	Status   string         `json:"status"` // "loaded", "error", "removed", "disabled"
	Error    string         `json:"error,omitempty"`
	Hash     string         `json:"hash"`               // SHA-256 of .so file
	Filename string         `json:"filename"`           // original .so/.dylib filename
	HasGraph bool           `json:"hasGraph,omitempty"` // exec provider implements GraphProvider
	TabLabel string         `json:"tabLabel,omitempty"` // for tab/feature/dashboard types
}

PluginInfo is the API-facing summary of a loaded plugin.

Jump to

Keyboard shortcuts

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