Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseEvent ¶
type BaseEvent struct {
// contains filtered or unexported fields
}
BaseEvent provides common event functionality
func NewBaseEvent ¶
NewBaseEvent creates a new base event
type DispatchError ¶
type DispatchError struct {
Errors []error
}
DispatchError represents errors that occurred during event dispatch
func (*DispatchError) Error ¶
func (e *DispatchError) Error() string
type Event ¶
type Event interface {
// EventID returns the unique identifier of the event
EventID() string
// EventType returns the type of the event
EventType() string
// Timestamp returns when the event occurred
Timestamp() time.Time
// Data returns the event data
Data() any
}
Event represents a domain event
type EventDispatcher ¶
type EventDispatcher struct {
// contains filtered or unexported fields
}
EventDispatcher dispatches events to registered handlers
func NewEventDispatcher ¶
func NewEventDispatcher() *EventDispatcher
NewEventDispatcher creates a new event dispatcher
func (*EventDispatcher) Dispatch ¶
func (d *EventDispatcher) Dispatch(ctx context.Context, event Event) error
Dispatch dispatches an event to all registered handlers
func (*EventDispatcher) RegisterHandler ¶
func (d *EventDispatcher) RegisterHandler(eventType string, handler EventHandler)
RegisterHandler registers an event handler for a specific event type
type EventHandler ¶
type EventHandler interface {
// Handle processes the event
Handle(ctx context.Context, event Event) error
}
EventHandler handles domain events
type EventStore ¶
type EventStore interface {
// Save saves an event
Save(ctx context.Context, event Event) error
// Load loads events for an aggregate
Load(ctx context.Context, aggregateID string) ([]Event, error)
}
EventStore stores events for later retrieval
type InMemoryEventStore ¶
type InMemoryEventStore struct {
// contains filtered or unexported fields
}
InMemoryEventStore implements EventStore using memory
func NewInMemoryEventStore ¶
func NewInMemoryEventStore() *InMemoryEventStore
NewInMemoryEventStore creates a new in-memory event store
Click to show internal directories.
Click to hide internal directories.