Marketplace

plugin-host

Other

togo plugin host — DB-driven runtime plugin registry, capabilities & workflow step composition

togo-framework
bash
togo install togo-framework/plugin-host

Install

bash
togo install togo-framework/plugin-host

Where a compiled togo plugin is wired at build time, plugin-host adds a runtime layer (the sentra-style plugins table): an admin can enable/disable a hosted plugin, change its config, and reorder navigation — live, persisted through a pluggable store, no restart. Each hosted plugin can contribute capabilities that call other togo plugins or trigger a workflow as step management.

Concepts

  • Hosted plugin recordPlugin{Slug, Kind, Enabled, Config, Nav, Sort, LabelEN, LabelAR} stored via the Store interface (in-memory default; back it with a DB plugins table).
  • Runtime toggleEnable/Disable/Configure + Refresh() apply state without recompiling.
  • CapabilitiesRegisterCapability(slug, fn); RunCapability(ctx, slug, input) runs it, gated by the owning plugin's enabled state.
  • Workflow compositionWorkflowCapability(k, "name") returns a capability that triggers a workflow (uses the workflow plugin's steps).

Usage

go
ph, _ := pluginhost.FromKernel(k)

// Host a plugin (persisted), shown in nav, sorted.
ph.Register(pluginhost.Plugin{Slug: "newsletter", Kind: "capability", Enabled: true, Nav: true, Sort: 10, LabelEN: "Newsletter"})

// Toggle / configure at runtime — no restart.
ph.Disable("newsletter")
ph.Configure("newsletter", map[string]any{"from": "news@acme.io", "double_optin": true})
ph.Enable("newsletter")

// Contribute a capability that composes other plugins…
ph.RegisterCapability("newsletter.send", func(ctx context.Context, in map[string]any) (any, error) {
    // call mail / notifications / billing plugins here
    return nil, nil
})

// …or compose the workflow plugin as step management.
ph.RegisterCapability("onboard", pluginhost.WorkflowCapability(k, "onboarding"))
out, err := ph.RunCapability(ctx, "onboard", map[string]any{"user_id": 42})

nav := ph.Nav() // enabled + nav-visible plugins, in sort order (for a sidebar)

REST API

Method
Path
Description
GET/api/plugin-host/pluginslist hosted plugins (sorted)
GET/api/plugin-host/dashboardplugins + nav + capabilities
POST/api/plugin-host/plugins/{slug}/toggleenable/disable
POST/api/plugin-host/plugins/{slug}/configuremerge config (JSON body)
GET/api/plugin-host/capabilitieslist capability slugs
POST/api/plugin-host/capabilities/{slug}/runrun a capability (JSON input)
Rows per page
1–6 of 6
Page 1 of 1

Configuration

No required env. Storage defaults to a bounded in-memory store; implement the Store interface (Upsert/Get/All/Delete) and call ph.WithStore(db) to host plugins in a database plugins table for true runtime, multi-instance control.


<div align="center"> <h3>Premium sponsors</h3> <p> <a href="https://id8media.com"><strong>ID8 Media</strong></a> &nbsp;·&nbsp; <a href="https://one-studio.co"><strong>One Studio</strong></a> </p> <p><sub>Support togo — <a href="https://github.com/sponsors/fadymondy">become a sponsor</a>.</sub></p> </div>