Documentation
¶
Overview ¶
Package pluginhost is a database-driven runtime plugin/capability registry for togo (the sentra-style "plugins table"): host plugins over a data store, enable/disable/configure them at runtime without a restart, and let each hosted plugin contribute capabilities/steps that compose other togo plugins — including the workflow plugin as step management.
Where a compiled togo plugin is wired at build time, plugin-host adds a *runtime* layer: an admin can toggle a plugin on/off, change its config, and reorder navigation live, all persisted through a pluggable Store.
Index ¶
- type CapabilityFunc
- type Plugin
- type Service
- func (s *Service) Capabilities() []string
- func (s *Service) ConfigValue(slug, key string) (any, bool)
- func (s *Service) Configure(slug string, cfg map[string]any) error
- func (s *Service) Disable(slug string) error
- func (s *Service) Enable(slug string) error
- func (s *Service) Get(slug string) (Plugin, bool)
- func (s *Service) IsEnabled(slug string) bool
- func (s *Service) List() []Plugin
- func (s *Service) Nav() []Plugin
- func (s *Service) Refresh()
- func (s *Service) Register(p Plugin)
- func (s *Service) RegisterCapability(slug string, fn CapabilityFunc)
- func (s *Service) RunCapability(ctx context.Context, slug string, input map[string]any) (any, error)
- func (s *Service) WithStore(store Store) *Service
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CapabilityFunc ¶
CapabilityFunc is a runtime capability a hosted plugin contributes. It can call other togo plugins or trigger a workflow.
func WorkflowCapability ¶
func WorkflowCapability(k *togo.Kernel, workflowName string) CapabilityFunc
WorkflowCapability builds a CapabilityFunc that triggers a named workflow via the workflow plugin — this is how a hosted plugin uses workflow as step management. Register it with RegisterCapability.
s.RegisterCapability("onboard", pluginhost.WorkflowCapability(k, "onboarding"))
type Plugin ¶
type Plugin struct {
Slug string `json:"slug"`
Kind string `json:"kind"` // e.g. capability, source, integration, ui
Enabled bool `json:"enabled"`
Config map[string]any `json:"config,omitempty"`
Sort int `json:"sort"` // nav/order weight
LabelEN string `json:"label_en,omitempty"`
LabelAR string `json:"label_ar,omitempty"`
}
Plugin is a hosted plugin/capability record (the row in the plugins table).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the plugin-host runtime stored on the kernel (k.Get("plugin-host")).
func FromKernel ¶
FromKernel returns the plugin-host Service.
func (*Service) Capabilities ¶
Capabilities lists registered capability slugs.
func (*Service) ConfigValue ¶
ConfigValue returns a single config value for a plugin.
func (*Service) Enable ¶
Enable / Disable toggle a plugin at runtime (persisted + applied immediately).
func (*Service) Refresh ¶
func (s *Service) Refresh()
Refresh re-reads the store and applies the enabled-state cache. Call after a store mutation made outside this Service (the "no restart" reload).
func (*Service) Register ¶
Register adds or updates a hosted plugin record, then refreshes runtime state.
func (*Service) RegisterCapability ¶
func (s *Service) RegisterCapability(slug string, fn CapabilityFunc)
RegisterCapability registers a runtime capability under a slug.