Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event interface {
EventName() string // Returns the name of the event (e.g., "UserCreated")
EventID() string // Returns a unique ID for this specific event instance
Timestamp() time.Time // Returns the time when the event occurred
}
Event is the base interface for all domain events.
type EventBus ¶
type EventBus interface {
Publisher
Subscriber
// 如果事件总线是后台进程,可以添加 Start 和 Stop 方法来管理其生命周期
Start(ctx context.Context) error
Stop(ctx context.Context) error
}
EventBus combines publishing and subscribing capabilities.
type EventHandler ¶
EventHandler is a function type that handles a specific event.
type Subscriber ¶
type Subscriber interface {
Subscribe(ctx context.Context, eventName string, handler EventHandler) error
Unsubscribe(ctx context.Context, eventName string, handler EventHandler) error
}
Subscriber is an interface for subscribing to events.
Click to show internal directories.
Click to hide internal directories.