Documentation
¶
Index ¶
- Constants
- Variables
- func AddTask(listID uuid.UUID, task string) command.Cmd[string]
- func DoneTasks(listID uuid.UUID, tasks ...string) command.Cmd[[]string]
- func HandleCommands(ctx context.Context, bus command.Bus, repo aggregate.Repository) <-chan error
- func RegisterCommands(r codec.Registerer)
- func RegisterEvents(r codec.Registerer)
- func RemoveTask(listID uuid.UUID, task string) command.Cmd[string]
- type Counter
- type List
- type TaskRemovedEvent
Constants ¶
const ( AddTaskCmd = "todo.list.add_task" RemoveTaskCmd = "todo.list.remove_task" DoneTaskCmd = "todo.list.done_task" )
Commands
const ( TaskAdded = "todo.list.task_added" TaskRemoved = "todo.list.task_removed" TasksDone = "todo.list.tasks_done" )
Events
const ListAggregate = "todo.list"
ListAggregate is the name of the List aggregate.
Variables ¶
var ListEvents = [...]string{ TaskAdded, TaskRemoved, TasksDone, }
ListEvents are all events of a todo list.
Functions ¶
func DoneTasks ¶
DoneTasks returns the command to mark the given tasks within the given list a done.
func HandleCommands ¶
HandleCommands handles todo list commands that are dispatched over the provided command bus until ctx is canceled. Command errors are sent into the returned error channel.
func RegisterCommands ¶
func RegisterCommands(r codec.Registerer)
RegisterCommands registers commands into a registry.
func RegisterEvents ¶
func RegisterEvents(r codec.Registerer)
RegisterEvents registers events into a registry.
Types ¶
type Counter ¶
type Counter struct {
*projection.Base
sync.RWMutex
// contains filtered or unexported fields
}
Counter is a read model that provides the number of active, removed, and archived tasks.
type List ¶
type List struct {
*aggregate.Base
*handler.BaseHandler
// contains filtered or unexported fields
}
List is a "todo" list.
func (*List) Contains ¶
Contains returns whether the list contains the given task (case-insensitive).
type TaskRemovedEvent ¶
type TaskRemovedEvent struct{ Task string }
TaskRemovedEvent is the event data for the TaskRemoved event.
You can use any type as event data. In this case, the event data is a struct. The event data types for the TaskAdded and TasksDone events are `string` and `[]string` respectively.