event

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DispatchQueueKey = "event_dispatch"

DispatchQueueKey 事件调度队列key

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus interface {
	// Register 注册事件监听器
	Register(dispatcher Dispatcher, listeners ...Listener)
	// Dispatch 事件调度
	Dispatch(dispatcher Dispatcher, data map[string]interface{}, opts ...DispatchOption)
}

Bus 事件总线接口

func New

func New(opts ...Option) Bus

New 初始化事件总线

type DispatchOption

type DispatchOption func(*dispatchOption)

func WithQueue

func WithQueue() DispatchOption

type Dispatcher

type Dispatcher string

Dispatcher 事件调度类型

type Listener

type Listener interface {
	Handle(data map[string]interface{})
}

Listener 事件监听器

type Option

type Option func(*bus)

func WithEventQueue

func WithEventQueue(queuePrefixKey string, queue contract.Consumer, queueProducer contract.Producer) Option

Jump to

Keyboard shortcuts

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