edgedriverhost

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package edgedriverhost 把外部 Driver Plugin Host 接入 edge 进程生命周期: 由 A4.5 的 desired-state + lockfile 驱动,在 edge 退出时优雅关闭、不留孤儿进程。

外部 driver 已通过 Driver Protocol v1 桥接进 edge 数据流:installed plugin 的 driver ID 被包装成 device.Adapter,handshake/descriptor/observation 经 DriverClient 接入监督循环;命令同样走 DriverClient.Execute,不把串口写成功冒充设备执行成功。

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfig = errors.New("edgedriverhost: invalid config")

ErrInvalidConfig 表示 edgedriverhost 配置不合法。

Functions

func CheckConflicts

func CheckConflicts(builtins, externalDriverIDs []string) error

CheckConflicts 拒绝任何与外部 driver ID 重名的内置 adapter。 冲突必须显式拒绝,绝不允许静默覆盖。

func DriverIDs

func DriverIDs(root, lockPath string) ([]string, error)

DriverIDs 返回 lockfile 中每个已安装插件贡献的 driver ID(去重、排序)。 贡献来自 registry.Manifest.Contributes 的 typed model——本包不再就地解析 plugin.yaml,消除与 internal/registry 的二次解析漂移。

没有 `contributes.drivers` 块的 manifest(如 Application/Connector,或旧版 Driver)贡献零个 ID;lock 条目对应的 manifest 无法读取/解析时 fail-closed。

Types

type Dialer

type Dialer interface {
	Dial(ctx context.Context, network, address string) (io.Closer, error)
}

Dialer 是握手后连接插件传输端点的接缝。host-only 生命周期从不拨号; 保留该接缝是为了 A4.7 数据流桥接可注入,而不改变 host 接线。

type Host

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

Host 是 edge 侧的外部 Driver Plugin Host 生命周期门面。

func New

func New(opts Options) (*Host, error)

New 校验 options 并构造 Host。直到 Start 被调用前都不会启动插件进程。

func (*Host) ApplySnapshot

func (h *Host) ApplySnapshot(ctx context.Context, tenant string, instances []api.PluginDesiredInstanceData) ([]api.PluginApplyResultData, error)

ApplySnapshot 实现 plugincontrol.Applier(委托内部 plugincontrol.Host)。

func (*Host) Close

func (h *Host) Close() error

Close 在 CloseTimeout 内优雅关闭所有受监督插件进程。幂等。 超过 deadline 后返回错误;底层 Manager.Close 仍会在其内部 ShutdownTimeout 内完成强制清理(Windows Job Object / Unix process group 防孤儿)。

func (*Host) DriverClient added in v0.2.0

func (h *Host) DriverClient(driverID string) (driver.DriverClient, error)

DriverClient returns the live DriverClient for the installed plugin that contributes driverID, or an error while the process is not yet running. The client is session-scoped: callers must re-resolve it after a restart.

func (*Host) DriverIDs

func (h *Host) DriverIDs() ([]string, error)

DriverIDs 返回已安装插件贡献的 driver ID(用于内置 adapter 冲突检测)。

func (*Host) Observe

Observe 实现 plugincontrol.Applier(委托内部 plugincontrol.Host)。

func (*Host) Run

func (h *Host) Run(ctx context.Context) error

Run 阻塞至 ctx 取消,然后在 CloseTimeout 内优雅关闭 host。

func (*Host) Start

func (h *Host) Start(ctx context.Context) error

Start 加载 desired-state 并启动已启用的 driver 实例。返回时 host 已完成装载; 实例进程监督在后台继续,直到 Close。装载失败会先清理中途已启动的实例, 避免 optional 路径留孤儿进程。

func (*Host) Tenant

func (h *Host) Tenant() string

Tenant 返回本 host 归属的租户(插件控制面同步按它隔离)。

type Options

type Options struct {
	// Manager 是插件实例控制面(注册安装/建实例/启动/关闭)。
	// *pluginhost.Manager 满足它;为 nil 时由 Runner 构造真实 Manager。
	Manager plugincontrol.HostManager
	// Runner 是插件进程启动接缝(生产 ExecRunner)。仅在 Manager 为 nil 时使用。
	Runner pluginhost.Runner
	// Dialer 是插件传输拨号接缝(host-only 阶段保留,不调用)。
	Dialer Dialer

	PluginsDir string
	StateDir   string
	LockPath   string
	Tenant     string
	// Secrets 是本地 secret provider(control-plane-sync.md §7)。nil 表示本 Edge
	// 不提供本地明文:任何绑定 secret:// handle 的实例都会 fail-closed。
	Secrets plugincontrol.SecretResolver

	Logger       *slog.Logger
	CloseTimeout time.Duration
}

Options 配置外部 Driver Plugin Host。Manager/Runner/Dialer 均为接缝: 测试注入 fake,生产用真实实现,任何测试都不启动真实第三方插件。

Jump to

Keyboard shortcuts

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