Documentation ¶
Index ¶
- func Close() error
- func PackData(topic string, payload interface{}) ([]byte, error)
- func Publish(ctx context.Context, topic string, message interface{}) error
- func SetEventbus(eventbus Eventbus)
- func Subscribe(ctx context.Context, topic string, handler EventHandler) error
- func Unsubscribe(ctx context.Context, topic string, handler EventHandler) error
- type Event
- type EventHandler
- type Eventbus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Subscribe ¶
func Subscribe(ctx context.Context, topic string, handler EventHandler) error
Subscribe 订阅事件
func Unsubscribe ¶
func Unsubscribe(ctx context.Context, topic string, handler EventHandler) error
Unsubscribe 取消订阅
Types ¶
type Event ¶
type EventHandler ¶
type EventHandler func(event *Event)
type Eventbus ¶
type Eventbus interface { // Close 关闭事件总线 Close() error // Publish 发布事件 Publish(ctx context.Context, topic string, message interface{}) error // Subscribe 订阅事件 Subscribe(ctx context.Context, topic string, handler EventHandler) error // Unsubscribe 取消订阅 Unsubscribe(ctx context.Context, topic string, handler EventHandler) error }
Click to show internal directories.
Click to hide internal directories.