Documentation
¶
Overview ¶
Package localbroker contains the shared in-process broker implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrClosed = errors.New("local broker: closed")
ErrClosed is returned when publishing or subscribing after the broker closes. ErrClosed 表示 broker 已关闭后再执行发布或订阅操作时返回的错误。
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker is an in-process best-effort pub/sub broker. Broker 进程内尽力而为的发布/订阅 broker,按 topic 维护 handler 订阅表。
func (*Broker) Close ¶
Close closes the broker and removes all subscriptions. Close 关闭 broker 并清空所有订阅。
type Message ¶
type Message struct {
Topic string // 消息所属 topic
Data []byte // 消息原始字节
SourceNode string // 发布消息的节点 ID
}
Message is delivered to subscribed handlers. Message 是投递给订阅 handler 的消息,包含 topic、原始数据和来源节点。
type Subscription ¶
type Subscription interface {
Close() error
}
Subscription represents one local broker subscription. Subscription 表示一个本地 broker 订阅句柄。
Click to show internal directories.
Click to hide internal directories.