Documentation
¶
Index ¶
- func RebuildNotice(dir string) string
- type Manager
- func (m *Manager) ApplyProjectStates(states map[string][]byte) []string
- func (m *Manager) ApplyUserStates(states map[string][]byte) []string
- func (m *Manager) Dashboard() sdk.DashboardProvider
- func (m *Manager) ExecProviders() map[string]sdk.ExecProvider
- func (m *Manager) ExportProjectStates() map[string][]byte
- func (m *Manager) ExportUserStates() map[string][]byte
- func (m *Manager) Features() map[string]sdk.TabProvider
- func (m *Manager) GraphData(ctx context.Context) map[string]sdk.GraphInfo
- func (m *Manager) HasPlugins() bool
- func (m *Manager) InteractProviders() map[string]sdk.InteractProvider
- func (m *Manager) List() []PluginInfo
- func (m *Manager) MarkRemoved(filename string) (restartRequired bool)
- func (m *Manager) PluginDataDir(name string) string
- func (m *Manager) PluginDir() string
- func (m *Manager) ProxyHooks() []sdk.ProxyHook
- func (m *Manager) RunRequestHook(ctx context.Context, info sdk.RequestInfo, rawReq []byte) ([]byte, error)
- func (m *Manager) RunResponseHook(ctx context.Context, info sdk.RequestInfo, rawResp []byte) ([]byte, error)
- func (m *Manager) Shutdown()
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) StartDisabled() error
- func (m *Manager) TabProviders() map[string]sdk.TabProvider
- type PluginInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RebuildNotice ¶
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 ¶
NewManager creates a plugin manager that loads plugins from pluginDir.
func (*Manager) ApplyProjectStates ¶
ApplyProjectStates is the ProjectStatefulPlugin analogue of ApplyUserStates.
func (*Manager) ApplyUserStates ¶
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 ¶
ExportProjectStates is the ProjectStatefulPlugin analogue of ExportUserStates.
func (*Manager) ExportUserStates ¶
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 ¶
GraphData collects network graph data from all connected ExecProviders that implement GraphProvider. Returns a map keyed by provider name.
func (*Manager) HasPlugins ¶
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 ¶
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 ¶
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 ¶
PluginDir returns the directory where plugin .so/.dylib files are stored.
func (*Manager) ProxyHooks ¶
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 ¶
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 ¶
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.