Documentation ¶
Overview ¶
Package events provides interfaces for publishing and handling domain events in Go. In Domain Driven Design, a domain event is a way of indicating that some event has happened that has relevance to the domain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterCreateHook ¶
type AfterCreateHook interface {
AfterCreate() *Event
}
AfterCreateHook is used for entities to trigger events after being created
type AfterDeleteHook ¶
type AfterDeleteHook interface {
AfterDelete() *Event
}
AfterDeleteHook is used for entities to trigger events after being deleted
type AfterUpdateHook ¶
type AfterUpdateHook interface {
AfterUpdate() *Event
}
AfterUpdateHook is used for entities to trigger events after being updated
type BeforeCreateHook ¶
type BeforeCreateHook interface {
BeforeCreate() *Event
}
BeforeCreateHook is used for entities to trigger events before being created
type BeforeDeleteHook ¶
type BeforeDeleteHook interface {
BeforeDelete() *Event
}
BeforeDeleteHook is used for entities to trigger events before being deleted
type BeforeUpdateHook ¶
type BeforeUpdateHook interface {
BeforeUpdate() *Event
}
BeforeUpdateHook is used for entities to trigger events before being updated
type ErrorHandler ¶
type ErrorHandler func(error)
ErrorHandler defines the function signature required for handling errors
type Event ¶
type Event struct { UUID string `json:"uuid"` CreatedAt time.Time `json:"created_at"` Name string `json:"name"` Data interface{} `json:"data"` }
Event is a generic wrapper for all domain events
type EventHandler ¶
EventHandler defines the function signature required for handling events
type Listener ¶
type Listener interface { // RegisterHandler registers an event handler for events of the given string name RegisterHandler(string, EventHandler) // Listen spawns a non-blocking goroutine to listen for new events Listen(ErrorHandler) // Halt stops the listen goroutine Halt() }
Listener defines the interface required for listening for new events and handling them