Documentation ¶
Index ¶
- Constants
- Variables
- func SetupDomain(commandBus *bus.CommandHandler, eventStore eh.EventStore, local HandlerAdder, ...) error
- type AddItem
- type Aggregate
- type CheckAllItems
- type CheckItem
- type Create
- type Delete
- type HandlerAdder
- type ItemAddedData
- type ItemCheckedData
- type ItemDescriptionSetData
- type ItemRemovedData
- type Projector
- type RemoveCompletedItems
- type RemoveItem
- type SetItemDescription
- type TodoItem
- type TodoList
Constants ¶
const ( // CreateCommand is the type for the Create command. CreateCommand = eh.CommandType("todolist:create") // DeleteCommand is the type for the Delete command. DeleteCommand = eh.CommandType("todolist:delete") // AddItemCommand is the type for the AddItem command. AddItemCommand = eh.CommandType("todolist:add_item") // RemoveItemCommand is the type for the RemoveItem command. RemoveItemCommand = eh.CommandType("todolist:remove_item") // RemoveCompletedItemsCommand is the type for the RemoveCompletedItems command. RemoveCompletedItemsCommand = eh.CommandType("todolist:remove_completed_items") // SetItemDescriptionCommand is the type for the SetItemDescription command. SetItemDescriptionCommand = eh.CommandType("todolist:set_item_description") // CheckItemCommand is the type for the CheckItem command. CheckItemCommand = eh.CommandType("todolist:check_item") // CheckAllItemsCommand is the type for the CheckAllItems command. CheckAllItemsCommand = eh.CommandType("todolist:check_all_items") )
const ( // Created is the event after a todo list is created. Created = eh.EventType("todolist:created") // Deleted is the event after a todo list is deleted. Deleted = eh.EventType("todolist:deleted") // ItemAdded is the event after a todo item is added. ItemAdded = eh.EventType("todolist:item_added") // ItemRemoved is the event after a todo item is removed. ItemRemoved = eh.EventType("todolist:item_removed") // ItemDescriptionSet is the event after a todo item's description is set. ItemDescriptionSet = eh.EventType("todolist:item_description_set") // ItemChecked is the event after a todo item's checked status is changed. ItemChecked = eh.EventType("todolist:item_checked") )
const AggregateType = eh.AggregateType("todolist")
AggregateType is the aggregate type for the todo list.
Variables ¶
var TimeNow = time.Now
TimeNow is a mockable version of time.Now.
Functions ¶
func SetupDomain ¶
func SetupDomain( commandBus *bus.CommandHandler, eventStore eh.EventStore, local HandlerAdder, repo eh.ReadWriteRepo, ) error
SetupDomain sets up the Todo domain.
Types ¶
type AddItem ¶
AddItem adds a todo item.
func (*AddItem) AggregateID ¶
func (*AddItem) AggregateType ¶
func (c *AddItem) AggregateType() eh.AggregateType
func (*AddItem) CommandType ¶
func (c *AddItem) CommandType() eh.CommandType
type Aggregate ¶
type Aggregate struct { *events.AggregateBase // contains filtered or unexported fields }
Aggregate is an aggregate for a todo list.
func (*Aggregate) ApplyEvent ¶
ApplyEvent implements the ApplyEvent method of the eventhorizon.Aggregate interface.
type CheckAllItems ¶
CheckAllItems sets the checked status of all todo items.
func (*CheckAllItems) AggregateID ¶
func (c *CheckAllItems) AggregateID() uuid.UUID
func (*CheckAllItems) AggregateType ¶
func (c *CheckAllItems) AggregateType() eh.AggregateType
func (*CheckAllItems) CommandType ¶
func (c *CheckAllItems) CommandType() eh.CommandType
type CheckItem ¶
type CheckItem struct { ID uuid.UUID `json:"id"` ItemID int `json:"item_id"` Checked bool `json:"checked"` }
CheckItem sets the checked status of a todo item.
func (*CheckItem) AggregateID ¶
func (*CheckItem) AggregateType ¶
func (c *CheckItem) AggregateType() eh.AggregateType
func (*CheckItem) CommandType ¶
func (c *CheckItem) CommandType() eh.CommandType
type Create ¶
Create creates a new todo list.
func (*Create) AggregateID ¶
func (*Create) AggregateType ¶
func (c *Create) AggregateType() eh.AggregateType
func (*Create) CommandType ¶
func (c *Create) CommandType() eh.CommandType
type Delete ¶
Delete deletes a todo list.
func (*Delete) AggregateID ¶
func (*Delete) AggregateType ¶
func (c *Delete) AggregateType() eh.AggregateType
func (*Delete) CommandType ¶
func (c *Delete) CommandType() eh.CommandType
type HandlerAdder ¶ added in v0.15.0
type HandlerAdder interface {
AddHandler(context.Context, eh.EventMatcher, eh.EventHandler) error
}
type ItemAddedData ¶
type ItemAddedData struct { ItemID int `json:"item_id" bson:"item_id"` Description string `json:"description" bson:"description"` }
ItemAddedData is the event data for the ItemAdded event.
type ItemCheckedData ¶
type ItemCheckedData struct { ItemID int `json:"item_id" bson:"item_id"` Checked bool `json:"checked" bson:"checked"` }
ItemCheckedData is the event data for the ItemChecked event.
type ItemDescriptionSetData ¶
type ItemDescriptionSetData struct { ItemID int `json:"item_id" bson:"item_id"` Description string `json:"description" bson:"description"` }
ItemDescriptionSetData is the event data for the ItemDescriptionSet event.
type ItemRemovedData ¶
type ItemRemovedData struct {
ItemID int `json:"item_id" bson:"item_id"`
}
ItemRemovedData is the event data for the ItemRemoved event.
type Projector ¶
type Projector struct{}
Projector is a projector of todo list events on the TodoList read model.
func (*Projector) Project ¶
func (p *Projector) Project(ctx context.Context, event eh.Event, entity eh.Entity) (eh.Entity, error)
Project implements the Project method of the eventhorizon.Projector interface.
func (*Projector) ProjectorType ¶
ProjectorType implements the ProjectorType method of the eventhorizon.Projector interface.
type RemoveCompletedItems ¶
RemoveCompletedItems removes all completed todo items.
func (*RemoveCompletedItems) AggregateID ¶
func (c *RemoveCompletedItems) AggregateID() uuid.UUID
func (*RemoveCompletedItems) AggregateType ¶
func (c *RemoveCompletedItems) AggregateType() eh.AggregateType
func (*RemoveCompletedItems) CommandType ¶
func (c *RemoveCompletedItems) CommandType() eh.CommandType
type RemoveItem ¶
RemoveItem removes a todo item.
func (*RemoveItem) AggregateID ¶
func (c *RemoveItem) AggregateID() uuid.UUID
func (*RemoveItem) AggregateType ¶
func (c *RemoveItem) AggregateType() eh.AggregateType
func (*RemoveItem) CommandType ¶
func (c *RemoveItem) CommandType() eh.CommandType
type SetItemDescription ¶
type SetItemDescription struct { ID uuid.UUID `json:"id"` ItemID int `json:"item_id"` Description string `json:"desc"` }
SetItemDescription sets the description of a todo item.
func (*SetItemDescription) AggregateID ¶
func (c *SetItemDescription) AggregateID() uuid.UUID
func (*SetItemDescription) AggregateType ¶
func (c *SetItemDescription) AggregateType() eh.AggregateType
func (*SetItemDescription) CommandType ¶
func (c *SetItemDescription) CommandType() eh.CommandType
type TodoItem ¶
type TodoItem struct { ID int `json:"id" bson:"id"` Description string `json:"desc" bson:"desc"` Completed bool `json:"completed" bson:"completed"` }
TodoItem represents each item that can be completed in the todo list.
type TodoList ¶
type TodoList struct { ID uuid.UUID `json:"id" bson:"_id"` Version int `json:"version" bson:"version"` Items []*TodoItem `json:"items" bson:"items"` CreatedAt time.Time `json:"created_at" bson:"created_at"` UpdatedAt time.Time `json:"updated_at" bson:"updated_at"` }
TodoList is the read model for the todo list.
func (*TodoList) AggregateVersion ¶
AggregateVersion implements the AggregateVersion method of the eventhorizon.Versionable interface.