Help us shape the future of Go! Take the 2026 Go Developer Survey

hotplug

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package hotplug 运行时插拔与原子热替换:启停视图(Plugboard)+ 泛型快照持有点(Holder)。 适用「文件管定义、页面管状态」的可插拔组件——reload/启停构建新快照后整体 Store, 运行中请求继续用旧快照跑完,新请求即时用新快照。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Holder

type Holder[T any] struct {
	// contains filtered or unexported fields
}

Holder 泛型原子快照持有点:读无锁,换整体原子。

func NewHolder

func NewHolder[T any]() *Holder[T]

NewHolder 构造空持有点(Load 返回 nil,直到首次 Store)。

func (*Holder[T]) Load

func (h *Holder[T]) Load() *T

Load 当前快照(可能为 nil——装配完成前)。

func (*Holder[T]) Store

func (h *Holder[T]) Store(v *T)

Store 原子换新。

type Plugboard

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

Plugboard 启停视图(登记 id → 是否启用)。并发安全;nil 指针=全启用 (未接插拔的测试/装配路径零成本兼容)。未登记 id 视为启用——注册表校验才是 错误路径,插拔视图不越权拦截。

func NewPlugboard

func NewPlugboard(all []string, disabled map[string]bool) *Plugboard

NewPlugboard 构造:all=登记 id 全集;disabled=被禁集合(含已不在册 id 时忽略)。

func (*Plugboard) Disabled

func (p *Plugboard) Disabled() []string

Disabled 被禁 id 列表(字典序——可观测面输出稳定,不随 map 迭代漂移)。

func (*Plugboard) Enabled

func (p *Plugboard) Enabled(id string) bool

Enabled 是否启用。

Jump to

Keyboard shortcuts

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