Documentation
¶
Overview ¶
Package plugin is the host side of tool plugins: a kind=tool binary under plugins/tools/<key>/ registers as an ordinary tool (grid, palette, access rules, config page) whose routes reverse-proxy to the plugin's HTTP server on a unix socket. The process is spawned on first use, held for at most DefaultHold, and idle-killed by the pool sweeper unless keep_warm.
Index ¶
- Constants
- Variables
- type Pool
- func (p *Pool) BuildModule(f connplugin.Found) tool.Module
- func (p *Pool) Inflight() int
- func (p *Pool) KillAll()
- func (p *Pool) Load(dir string, enabled func(string) bool, ...) int
- func (p *Pool) Remove(key string)
- func (p *Pool) Start()
- func (p *Pool) Sweep() int
- func (p *Pool) Version(key string) (string, bool)
- type Proxy
- type Runner
Constants ¶
const DefaultHold = 10 * time.Second
DefaultHold bounds how long a request waits for a cold plugin to finish its handshake before the host answers 503.
const DefaultIdle = 10 * time.Minute
DefaultIdle is how long an unused tool plugin stays running; WICK_TOOL_PLUGIN_IDLE (a Go duration) overrides it.
Variables ¶
var ErrNotReady = errors.New("tool plugin not ready")
ErrNotReady is returned by Acquire when the plugin did not come up within the hold window (or failed to start).
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool holds every loaded tool plugin's Runner and sweeps idle ones, using the same rule as the connector plugin sweeper: not warm, nothing in flight, unused for longer than the idle TTL.
func NewPool ¶
func NewPool() *Pool
NewPool returns an empty pool; call Start once tools are loaded.
func (*Pool) BuildModule ¶
func (p *Pool) BuildModule(f connplugin.Found) tool.Module
BuildModule turns one discovered kind=tool plugin into a tool.Module whose routes proxy to the plugin, and registers its runner with the pool.
func (*Pool) KillAll ¶
func (p *Pool) KillAll()
KillAll stops the sweeper and every process (app shutdown).
func (*Pool) Load ¶
func (p *Pool) Load(dir string, enabled func(string) bool, record func(key, kind, version string) error, register func(tool.Module)) int
Load registers every enabled, verified kind=tool plugin under dir with register (tools.Register) and returns how many were registered. Call it before tools.All() so the plugin's config rows are seeded like a built-in tool's. record (optional) is told the kind + version of each plugin.
func (*Pool) Remove ¶
Remove stops the process of tool plugin key and drops it from the pool, ahead of an uninstall deleting its files.
func (*Pool) Start ¶
func (p *Pool) Start()
Start warms keep_warm tools and starts the idle sweeper.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy forwards /tools/{key}/* to one tool plugin's unix socket.
func (*Proxy) ServeWebhook ¶
func (p *Proxy) ServeWebhook(c *tool.WebhookCtx, cfgKeys []string)
ServeWebhook proxies a manifest-declared webhook route: no session, no user headers, never wrapped.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner owns the lifecycle of one tool plugin: at most one process, spawned on first use (singleflight, so N concurrent cold requests cause one spawn), idle-killed by the pool sweeper unless keep_warm or a request (including a long-lived SSE/websocket one) is still in flight.
func (*Runner) Acquire ¶
func (r *Runner) Acquire(ctx context.Context, cfg map[string]string) (http.RoundTripper, func(), error)
Acquire returns a transport to the running plugin (spawning it if needed) with cfg pushed, and a release func the caller must call when the request — including any streamed body — is finished. It waits at most the hold window for a cold start; the spawn keeps going in the background so the next request finds it ready.