Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventBus ¶
type EventBus interface { Register(eventType string, handler func(events.DomainEvent)) HandlerID Unregister(eventType string, id HandlerID) Publish(ctx contextx.Contextx, event events.DomainEvent) }
EventBus defines the interface for an event bus.
func NewKafkaEventBus ¶
func NewKafkaEventBus(app *configx.Application, topic string) (EventBus, error)
NewKafkaEventBus creates a new Kafka event bus
type KafkaEventBus ¶
type KafkaEventBus struct {
// contains filtered or unexported fields
}
func (*KafkaEventBus) Publish ¶
func (bus *KafkaEventBus) Publish(ctx contextx.Contextx, event events.DomainEvent)
Publish publishes an event to all registered handlers
func (*KafkaEventBus) Register ¶
func (bus *KafkaEventBus) Register(eventType string, handler func(events.DomainEvent)) HandlerID
Register registers an event handler and returns a unique handler ID
func (*KafkaEventBus) Unregister ¶
func (bus *KafkaEventBus) Unregister(eventType string, id HandlerID)
Unregister unregisters an event handler by its ID
type MemoryEventBus ¶
type MemoryEventBus struct {
// contains filtered or unexported fields
}
func (*MemoryEventBus) Publish ¶
func (bus *MemoryEventBus) Publish(ctx contextx.Contextx, event events.DomainEvent)
Publish 發布事件
func (*MemoryEventBus) Register ¶
func (bus *MemoryEventBus) Register(eventType string, handler func(events.DomainEvent)) HandlerID
Register 註冊事件處理器並返回處理器的唯一標識符
func (*MemoryEventBus) Unregister ¶
func (bus *MemoryEventBus) Unregister(eventType string, id HandlerID)
Unregister 取消註冊事件處理器
Click to show internal directories.
Click to hide internal directories.