mqx

package
v0.0.0-...-fefde71 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

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

func NewMemoryEventBus

func NewMemoryEventBus() EventBus

NewMemoryEventBus 創建一個新的內存事件總線

type HandlerID

type HandlerID int

HandlerID defines the type for handler ID.

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 取消註冊事件處理器

Jump to

Keyboard shortcuts

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