package
Version:
v0.7.2
Opens a new window with list of versions in this module.
Published: Oct 21, 2026
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package progress 泛型事件总线。
多订阅者广播,每个订阅者 64 缓冲,满了就丢(观测数据允许有损)。
发布永不阻塞(订阅者慢不拖慢主链路)。
type Bus[T any] struct {
}
Bus 泛型多订阅者广播总线。
Dropped 累计丢弃的事件数(订阅者积压时)。有损是声明的设计,
计数让"进度条停在中间态"可归因。
func (b *Bus[T]) Publish(e T)
Publish 非阻塞广播。nil Bus 安全(no-op)。
Subscribe 注册订阅者;返回取消函数(ctx 结束也会自动取消)。
nil Bus 安全:返回永不产出的 nil channel 与 no-op cancel(与 Publish/Dropped
同一 nil 契约)。
cancel 与 ctx 结束双向收口:任一发生,监听 goroutine 都会退出——
此前手动 cancel 只删 channel 不唤醒监听 goroutine,ctx 为 Background 时
每个订阅者永久泄漏一个 goroutine + 一条残留 channel。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.