host

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package host manages the lifecycle of external plugins — plugins that run as separate processes and communicate with the host over net/rpc.

This package handles the subprocess and RPC transport details for the exec: plugin type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DescribePlugin

func DescribePlugin(path string) (plugin.Descriptor, error)

DescribePlugin launches a plugin binary, calls Describe(), kills it, and returns the descriptor. It never adds the process to the live clients map. Used by the catalog endpoint to get schema info without starting sampling.

Types

type Host

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

Host manages the lifecycle of external (subprocess) plugins.

func NewHost

func NewHost(logger *slog.Logger) *Host

NewHost creates a new plugin host.

func (*Host) Evict

func (h *Host) Evict(id string)

Evict removes a plugin's record so LaunchPlugin will start a fresh process. Call this after detecting a crash before attempting relaunch.

func (*Host) GetPlugin

func (h *Host) GetPlugin(id string) (plugin.Plugin, error)

GetPlugin returns a previously launched plugin, or an error if not running.

func (*Host) IsAlive

func (h *Host) IsAlive(id string) bool

IsAlive reports whether the plugin subprocess is still running.

func (*Host) LaunchPlugin

func (h *Host) LaunchPlugin(ctx context.Context, id, path string) (plugin.Plugin, error)

LaunchPlugin starts an external plugin subprocess and returns the Plugin interface. If the plugin is already running, the existing instance is returned.

func (*Host) SampleWithTimeout

func (h *Host) SampleWithTimeout(id string, timeout time.Duration) (plugin.Payload, error)

SampleWithTimeout calls Sample() on a running plugin, returning an error if it doesn't respond within timeout.

func (*Host) StopAll

func (h *Host) StopAll()

StopAll terminates all running external modules.

func (*Host) StopPlugin

func (h *Host) StopPlugin(id string) error

StopPlugin terminates a running external plugin.

type PluginHost

type PluginHost interface {
	LaunchPlugin(ctx context.Context, id, path string) (plugin.Plugin, error)
	IsAlive(id string) bool
	Evict(id string)
}

PluginHost is the interface Sampler uses to manage external plugin processes. Declared here so callers can substitute a fake in tests.

Jump to

Keyboard shortcuts

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