memoryevent

package
v0.0.0-...-aed2785 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerRecord

type HandlerRecord struct {
	ID      string              // 每个订阅都需要分配一个 ID,方便日志查找及取消订阅
	Handler dinfra.EventHandler // 事件的处理函数
}

func CopyHandlers

func CopyHandlers(node *Node, records []*HandlerRecord) []*HandlerRecord

func MacthHandlers

func MacthHandlers(node *Node, keys []string) []*HandlerRecord

func RemoveRecord

func RemoveRecord(node *Node, subscribeID string) *HandlerRecord

type MemoryEventBus

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

func NewMemoryEventBus

func NewMemoryEventBus(
	logger dinfra.Logger,
) *MemoryEventBus

func (*MemoryEventBus) Publish

func (bus *MemoryEventBus) Publish(
	context context.Context,
	event *dinfra.Event,
) (*dinfra.Event, error)

func (*MemoryEventBus) Subscribe

func (bus *MemoryEventBus) Subscribe(
	topic string,
	handler dinfra.EventHandler,
) (string, error)

func (*MemoryEventBus) Unsubscribe

func (bus *MemoryEventBus) Unsubscribe(
	subscribeID string,
) error

type Node

type Node struct {
	Key      string                    // 节点的订阅字符
	Topic    string                    // 对应的主题
	Handlers map[string]*HandlerRecord // 对应的 handler 记录
	Children map[string]*Node          // 子项
}

做成一个简单的树结构,可以处理 + # 等特殊匹配

func BuildeNode

func BuildeNode(key string) *Node

func FindChild

func FindChild(node *Node, keys []string) (*Node, []string)

Jump to

Keyboard shortcuts

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