household

package
v0.0.0-...-059733a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeHouseholdCreated es.EventType = "HouseholdCreatedEvent"
	EventTypeHouseholdUpdated es.EventType = "HouseholdUpdatedEvent"
	EventTypeHouseholdDeleted es.EventType = "HouseholdDeletedEvent"

	EventTypeRoomAdded   es.EventType = "RoomAddedEvent"
	EventTypeRoomUpdated es.EventType = "RoomUpdatedEvent"
	EventTypeRoomDeleted es.EventType = "RoomDeletedEvent"
)
View Source
const (
	MinHouseholdNameLength = 3
	MaxHouseholdNameLength = 50

	MinHouseholdLocationLength = 3
	MaxHouseholdLocationLength = 50

	MaxHouseholdDescriptionLength = 200

	MinRoomNameLength = 3
	MaxRoomNameLength = 50
)
View Source
const (
	HouseholdAggregateType es.AggregateType = "HouseholdAggregate"
)

Variables

This section is empty.

Functions

func NewHouseholdAggregate

func NewHouseholdAggregate(aggregateContext es.AggregateContext) es.AggregateRoot

Types

type AddRoomCommand

type AddRoomCommand struct {
	HouseholdID string
	UserID      string
	RoomID      string
	Name        string
}

func (AddRoomCommand) AggregateID

func (c AddRoomCommand) AggregateID() es.AggregateID

func (AddRoomCommand) AggregateType

func (c AddRoomCommand) AggregateType() es.AggregateType

type CreateHouseholdCommand

type CreateHouseholdCommand struct {
	HouseholdID string
	UserID      string
	Name        string
	Location    string
	Description string
	Order       uint
}

func (CreateHouseholdCommand) AggregateID

func (c CreateHouseholdCommand) AggregateID() es.AggregateID

func (CreateHouseholdCommand) AggregateType

func (c CreateHouseholdCommand) AggregateType() es.AggregateType

type DeleteHouseholdCommand

type DeleteHouseholdCommand struct {
	HouseholdID string
	UserID      string
}

func (DeleteHouseholdCommand) AggregateID

func (c DeleteHouseholdCommand) AggregateID() es.AggregateID

func (DeleteHouseholdCommand) AggregateType

func (c DeleteHouseholdCommand) AggregateType() es.AggregateType

type DeleteRoomCommand

type DeleteRoomCommand struct {
	HouseholdID string
	UserID      string
	RoomID      string
}

func (DeleteRoomCommand) AggregateID

func (c DeleteRoomCommand) AggregateID() es.AggregateID

func (DeleteRoomCommand) AggregateType

func (c DeleteRoomCommand) AggregateType() es.AggregateType

type HouseholdAgregate

type HouseholdAgregate struct {
	es.AggregateContext

	UserID      c.UserID
	Name        HouseholdName
	Location    HouseholdLocation
	Description HouseholdDescription
	Order       uint

	Rooms Rooms

	Deleted bool
}

func (*HouseholdAgregate) ApplyEvent

func (a *HouseholdAgregate) ApplyEvent(event es.EventData)

func (*HouseholdAgregate) HandleCommand

func (a *HouseholdAgregate) HandleCommand(ctx context.Context, command es.Command) ([]es.EventData, error)

type HouseholdCreatedEvent

type HouseholdCreatedEvent struct {
	HouseholdID string `json:"householdId"`
	UserID      string `json:"userId"`
	Name        string `json:"name"`
	Location    string `json:"location"`
	Description string `json:"description"`
	Order       uint   `json:"order"`
	Timestamp   int64  `json:"timestamp"`
}

func (HouseholdCreatedEvent) EventType

func (e HouseholdCreatedEvent) EventType() es.EventType

type HouseholdDeletedEvent

type HouseholdDeletedEvent struct {
	HouseholdID string `json:"householdId"`
	UserID      string `json:"userId"`
}

func (HouseholdDeletedEvent) EventType

func (e HouseholdDeletedEvent) EventType() es.EventType

type HouseholdDescription

type HouseholdDescription string

func NewHouseholdDescription

func NewHouseholdDescription(description string) (HouseholdDescription, error)

func (HouseholdDescription) String

func (d HouseholdDescription) String() string

type HouseholdLocation

type HouseholdLocation string

func NewHouseholdLocation

func NewHouseholdLocation(location string) (HouseholdLocation, error)

func (HouseholdLocation) String

func (l HouseholdLocation) String() string

type HouseholdName

type HouseholdName string

func NewHouseholdName

func NewHouseholdName(name string) (HouseholdName, error)

func (HouseholdName) String

func (n HouseholdName) String() string

type HouseholdUpdatedEvent

type HouseholdUpdatedEvent struct {
	HouseholdID string `json:"householdId"`
	UserID      string `json:"userId"`
	Name        string `json:"name"`
	Location    string `json:"location"`
	Description string `json:"description"`
	Timestamp   int64  `json:"timestamp"`
}

func (HouseholdUpdatedEvent) EventType

func (e HouseholdUpdatedEvent) EventType() es.EventType

type Room

type Room struct {
	ID    RoomID
	Name  RoomName
	Order uint
}

func NewRoom

func NewRoom(id, name string, order uint) (Room, error)

func (Room) Update

func (r Room) Update(name string) (Room, error)

type RoomAddedEvent

type RoomAddedEvent struct {
	HouseholdID string `json:"householdId"`
	UserID      string `json:"userId"`
	RoomID      string `json:"roomId"`
	Name        string `json:"name"`
	Order       uint   `json:"order"`
	Timestamp   int64  `json:"timestamp"`
}

func (RoomAddedEvent) EventType

func (e RoomAddedEvent) EventType() es.EventType

type RoomDeletedEvent

type RoomDeletedEvent struct {
	HouseholdID string `json:"householdId"`
	UserID      string `json:"userId"`
	RoomID      string `json:"roomId"`
}

func (RoomDeletedEvent) EventType

func (e RoomDeletedEvent) EventType() es.EventType

type RoomID

type RoomID string

func NewRoomID

func NewRoomID(id string) (RoomID, error)

func (RoomID) String

func (id RoomID) String() string

type RoomName

type RoomName string

func NewRoomName

func NewRoomName(name string) (RoomName, error)

func (RoomName) String

func (n RoomName) String() string

type RoomUpdatedEvent

type RoomUpdatedEvent struct {
	HouseholdID string `json:"householdId"`
	UserID      string `json:"userId"`
	RoomID      string `json:"roomId"`
	Name        string `json:"name"`
	Order       uint   `json:"order"`
	Timestamp   int64  `json:"timestamp"`
}

func (RoomUpdatedEvent) EventType

func (e RoomUpdatedEvent) EventType() es.EventType

type Rooms

type Rooms map[RoomID]Room

func NewRooms

func NewRooms() Rooms

func (Rooms) Add

func (r Rooms) Add(room Room) error

func (Rooms) Count

func (r Rooms) Count() int

func (Rooms) FindByName

func (r Rooms) FindByName(name RoomName) (Room, bool)

func (Rooms) Get

func (r Rooms) Get(id RoomID) (Room, bool)

func (Rooms) Remove

func (r Rooms) Remove(id RoomID)

func (Rooms) Update

func (r Rooms) Update(room Room) error

func (Rooms) Without

func (r Rooms) Without(id RoomID) Rooms

type UpdateHouseholdCommand

type UpdateHouseholdCommand struct {
	HouseholdID string
	UserID      string
	Name        string
	Location    string
	Description string
}

func (UpdateHouseholdCommand) AggregateID

func (c UpdateHouseholdCommand) AggregateID() es.AggregateID

func (UpdateHouseholdCommand) AggregateType

func (c UpdateHouseholdCommand) AggregateType() es.AggregateType

type UpdateRoomCommand

type UpdateRoomCommand struct {
	HouseholdID string
	UserID      string
	RoomID      string
	Name        string
}

func (UpdateRoomCommand) AggregateID

func (c UpdateRoomCommand) AggregateID() es.AggregateID

func (UpdateRoomCommand) AggregateType

func (c UpdateRoomCommand) AggregateType() es.AggregateType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL