memory

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBusClosed = errors.New("memory event bus: closed")

ErrBusClosed 总线已关闭(Publish/Subscribe 拒绝)

Functions

This section is empty.

Types

type EventBus

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

EventBus 内存事件总线(queue / fanout 双语义,topic 内严格保序)

func NewEventBus

func NewEventBus() *EventBus

NewEventBus 创建内存事件总线

func (*EventBus) Close

func (b *EventBus) Close() error

Close 优雅关闭:拒绝新消息、等待在途分发排空

不关闭 queue(向 closed channel 写会 panic),改经 stopCh 通知各 分发循环排空后自行退出

func (*EventBus) Publish

func (b *EventBus) Publish(ctx context.Context, env *spi.DeliverEnvelope) error

Publish 发布投递指令(入队即返回,分发由 topic 专属 goroutine 串行执行)

信封按 Intent 路由 topic:IntentBroadcast → broadcast,其余 → deliver (与 NATS 适配器的 Publish 路由规则一致,信封语义跨驱动不变)

func (*EventBus) Subscribe

func (b *EventBus) Subscribe(ctx context.Context, topic spi.EventBusTopic, handler spi.EventHandler) error

Subscribe 订阅指定语义 topic(首条订阅拉起该 topic 的分发 goroutine)

func (*EventBus) SubscriberCount

func (b *EventBus) SubscriberCount(topic spi.EventBusTopic) int

SubscriberCount 订阅者计数(契约测试断言用)

Jump to

Keyboard shortcuts

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