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 ¶
- Variables
- func CheckConflicts(builtins, externalDriverIDs []string) error
- func DriverIDs(root, lockPath string) ([]string, error)
- type Dialer
- type Host
- func (h *Host) ApplySnapshot(ctx context.Context, tenant string, instances []api.PluginDesiredInstanceData) ([]api.PluginApplyResultData, error)
- func (h *Host) Close() error
- func (h *Host) DriverClient(driverID string) (driver.DriverClient, error)
- func (h *Host) DriverIDs() ([]string, error)
- func (h *Host) Observe(ctx context.Context, tenant string) ([]api.PluginInstallationStatusData, []api.PluginObservedInstanceData, error)
- func (h *Host) Run(ctx context.Context) error
- func (h *Host) Start(ctx context.Context) error
- func (h *Host) Tenant() string
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidConfig = errors.New("edgedriverhost: invalid config")
ErrInvalidConfig 表示 edgedriverhost 配置不合法。
Functions ¶
func CheckConflicts ¶
CheckConflicts 拒绝任何与外部 driver ID 重名的内置 adapter。 冲突必须显式拒绝,绝不允许静默覆盖。
Types ¶
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host 是 edge 侧的外部 Driver Plugin Host 生命周期门面。
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 ¶
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) Observe ¶
func (h *Host) Observe(ctx context.Context, tenant string) ([]api.PluginInstallationStatusData, []api.PluginObservedInstanceData, error)
Observe 实现 plugincontrol.Applier(委托内部 plugincontrol.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,生产用真实实现,任何测试都不启动真实第三方插件。