Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventBus ¶
type EventBus interface {
// Publish 发布事件
Publish(ctx context.Context, event domainEvent.DomainEvent) error
// Subscribe 订阅事件
Subscribe(handler EventHandler)
// Unsubscribe 取消订阅事件
Unsubscribe(handler EventHandler)
}
EventBus 事件总线接口
type EventHandler ¶
type EventHandler interface {
// Handle 事件处理器
Handle(ctx context.Context, event domainEvent.DomainEvent) error
// CanHandle 判断是否可以处理该事件
CanHandle(eventType string) bool
}
EventHandler 事件处理器接口
type InMemoryEventBus ¶
type InMemoryEventBus struct {
// contains filtered or unexported fields
}
InMemoryEventBus 基于内存的事件总线
func NewInMemoryEventBus ¶
func NewInMemoryEventBus() *InMemoryEventBus
func (*InMemoryEventBus) Publish ¶
func (bus *InMemoryEventBus) Publish(ctx context.Context, event domainEvent.DomainEvent) error
func (*InMemoryEventBus) Subscribe ¶
func (bus *InMemoryEventBus) Subscribe(handler EventHandler)
func (*InMemoryEventBus) Unsubscribe ¶
func (bus *InMemoryEventBus) Unsubscribe(handler EventHandler)
Click to show internal directories.
Click to hide internal directories.