Documentation ¶
Index ¶
- type CommandService
- func (s *CommandService) Close()
- func (s *CommandService) Create(ctx context.Context, cmd *restaurant_pb.CmdRestaurantCreate) (res *restaurant_pb.RestaurantCreated, err error)
- func (s *CommandService) CreateMenuCategory(ctx context.Context, cmd *restaurant_pb.CmdMenuCategoryCreate) (res *restaurant_pb.MenuCategoryCreated, err error)
- func (s *CommandService) CreateMenuItem(ctx context.Context, cmd *restaurant_pb.CmdMenuItemCreate) (res *restaurant_pb.MenuItemCreated, err error)
- func (s *CommandService) Delete(ctx context.Context, cmd *restaurant_pb.CmdRestaurantDelete) (res *restaurant_pb.RestaurantDeleted, err error)
- func (s *CommandService) DeleteMenuCategory(ctx context.Context, cmd *restaurant_pb.CmdMenuCategoryDelete) (res *restaurant_pb.MenuCategoryDeleted, err error)
- func (s *CommandService) DeleteMenuItem(ctx context.Context, cmd *restaurant_pb.CmdMenuItemDelete) (res *restaurant_pb.MenuItemDeleted, err error)
- func (s *CommandService) Update(ctx context.Context, cmd *restaurant_pb.CmdRestaurantUpdate) (res *restaurant_pb.RestaurantUpdated, err error)
- func (s *CommandService) UpdateMenuCategory(ctx context.Context, cmd *restaurant_pb.CmdMenuCategoryUpdate) (res *restaurant_pb.MenuCategoryUpdated, err error)
- func (s *CommandService) UpdateMenuItem(ctx context.Context, cmd *restaurant_pb.CmdMenuItemUpdate) (res *restaurant_pb.MenuItemUpdated, err error)
- type EventCreated
- type EventDeleted
- type EventMenuCategoryCreated
- type EventMenuCategoryDeleted
- type EventMenuCategoryUpdated
- type EventMenuItemCreated
- type EventMenuItemDeleted
- type EventMenuItemUpdated
- type EventUpdated
- type MenuCategory
- type MenuItem
- type QueryService
- type ReadRepository
- type Restaurant
- type WriteRepository
- func (repo *WriteRepository) Create(ctx context.Context, name string) (event *EventCreated, err error)
- func (repo *WriteRepository) CreateMenuCategory(ctx context.Context, restaurantID, name string) (event *EventMenuCategoryCreated, err error)
- func (repo *WriteRepository) CreateMenuItem(ctx context.Context, restaurantID, categoryID, name, description string) (event *EventMenuItemCreated, err error)
- func (repo *WriteRepository) Delete(ctx context.Context, id string) (event *EventDeleted, err error)
- func (repo *WriteRepository) DeleteMenuCategory(ctx context.Context, id string) (event *EventMenuCategoryDeleted, err error)
- func (repo *WriteRepository) DeleteMenuItem(ctx context.Context, restaurantID, id string) (event *EventMenuItemDeleted, err error)
- func (repo *WriteRepository) LoadAggregate(id string) (aggregate events.AggregateDB, err error)
- func (repo *WriteRepository) SaveEvents(aggregateID string, aggregateEvents []events.Event, originalVersion int) (err error)
- func (repo *WriteRepository) Update(ctx context.Context, id, name string) (event *EventUpdated, err error)
- func (repo *WriteRepository) UpdateMenuCategory(ctx context.Context, id, name string) (event *EventMenuCategoryUpdated, err error)
- func (repo *WriteRepository) UpdateMenuItem(ctx context.Context, restaurantID, categoryID, id, name, description string) (event *EventMenuItemUpdated, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandService ¶
type CommandService struct { restaurant_pb.UnimplementedCommandServiceServer // contains filtered or unexported fields }
func NewCommandService ¶
func (*CommandService) Close ¶
func (s *CommandService) Close()
func (*CommandService) Create ¶
func (s *CommandService) Create(ctx context.Context, cmd *restaurant_pb.CmdRestaurantCreate) (res *restaurant_pb.RestaurantCreated, err error)
func (*CommandService) CreateMenuCategory ¶
func (s *CommandService) CreateMenuCategory(ctx context.Context, cmd *restaurant_pb.CmdMenuCategoryCreate) (res *restaurant_pb.MenuCategoryCreated, err error)
func (*CommandService) CreateMenuItem ¶
func (s *CommandService) CreateMenuItem(ctx context.Context, cmd *restaurant_pb.CmdMenuItemCreate) (res *restaurant_pb.MenuItemCreated, err error)
func (*CommandService) Delete ¶
func (s *CommandService) Delete(ctx context.Context, cmd *restaurant_pb.CmdRestaurantDelete) (res *restaurant_pb.RestaurantDeleted, err error)
func (*CommandService) DeleteMenuCategory ¶
func (s *CommandService) DeleteMenuCategory(ctx context.Context, cmd *restaurant_pb.CmdMenuCategoryDelete) (res *restaurant_pb.MenuCategoryDeleted, err error)
func (*CommandService) DeleteMenuItem ¶
func (s *CommandService) DeleteMenuItem(ctx context.Context, cmd *restaurant_pb.CmdMenuItemDelete) (res *restaurant_pb.MenuItemDeleted, err error)
func (*CommandService) Update ¶
func (s *CommandService) Update(ctx context.Context, cmd *restaurant_pb.CmdRestaurantUpdate) (res *restaurant_pb.RestaurantUpdated, err error)
func (*CommandService) UpdateMenuCategory ¶
func (s *CommandService) UpdateMenuCategory(ctx context.Context, cmd *restaurant_pb.CmdMenuCategoryUpdate) (res *restaurant_pb.MenuCategoryUpdated, err error)
func (*CommandService) UpdateMenuItem ¶
func (s *CommandService) UpdateMenuItem(ctx context.Context, cmd *restaurant_pb.CmdMenuItemUpdate) (res *restaurant_pb.MenuItemUpdated, err error)
type EventCreated ¶
type EventCreated struct { ID string `bson:"id,omitempty" json:"id,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` }
func EventCreatedFromData ¶
func EventCreatedFromData(data bson.M) *EventCreated
func EventCreatedFromProto ¶
func EventCreatedFromProto(cmd *restaurant_pb.RestaurantCreated) *EventCreated
func (*EventCreated) AggregateID ¶
func (e *EventCreated) AggregateID() string
func (*EventCreated) Data ¶
func (e *EventCreated) Data() bson.M
func (*EventCreated) EventCategory ¶
func (e *EventCreated) EventCategory() string
func (*EventCreated) EventType ¶
func (e *EventCreated) EventType() string
func (*EventCreated) ToProto ¶
func (e *EventCreated) ToProto() proto.Message
type EventDeleted ¶
type EventDeleted struct { ID string `bson:"id,omitempty" json:"id,omitempty"` DeletedAt time.Time `bson:"deleted_at,omitempty" json:"deleted_at,omitempty"` }
func EventDeletedFromData ¶
func EventDeletedFromData(data bson.M) *EventDeleted
func EventDeletedFromProto ¶
func EventDeletedFromProto(cmd *restaurant_pb.RestaurantDeleted) *EventDeleted
func (*EventDeleted) AggregateID ¶
func (e *EventDeleted) AggregateID() string
func (*EventDeleted) Data ¶
func (e *EventDeleted) Data() bson.M
func (*EventDeleted) EventCategory ¶
func (e *EventDeleted) EventCategory() string
func (*EventDeleted) EventType ¶
func (e *EventDeleted) EventType() string
func (*EventDeleted) ToProto ¶
func (e *EventDeleted) ToProto() proto.Message
type EventMenuCategoryCreated ¶
type EventMenuCategoryCreated struct { ID string `bson:"id,omitempty" json:"id,omitempty"` RestaurantID string `bson:"restaurant_id,omitempty" json:"restaurant_id,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` }
func EventMenuCategoryCreatedFromData ¶
func EventMenuCategoryCreatedFromData(data bson.M) *EventMenuCategoryCreated
func EventMenuCategoryCreatedFromProto ¶
func EventMenuCategoryCreatedFromProto(cmd *restaurant_pb.MenuCategoryCreated) *EventMenuCategoryCreated
func (*EventMenuCategoryCreated) AggregateID ¶
func (e *EventMenuCategoryCreated) AggregateID() string
func (*EventMenuCategoryCreated) Data ¶
func (e *EventMenuCategoryCreated) Data() bson.M
func (*EventMenuCategoryCreated) EventCategory ¶
func (e *EventMenuCategoryCreated) EventCategory() string
func (*EventMenuCategoryCreated) EventType ¶
func (e *EventMenuCategoryCreated) EventType() string
func (*EventMenuCategoryCreated) ToProto ¶
func (e *EventMenuCategoryCreated) ToProto() proto.Message
type EventMenuCategoryDeleted ¶
type EventMenuCategoryDeleted struct { ID string `bson:"id,omitempty" json:"id,omitempty"` RestaurantID string `bson:"restaurant_id,omitempty" json:"restaurant_id,omitempty"` }
func EventMenuCategoryDeletedFromData ¶
func EventMenuCategoryDeletedFromData(data bson.M) *EventMenuCategoryDeleted
func EventMenuCategoryDeletedFromProto ¶
func EventMenuCategoryDeletedFromProto(cmd *restaurant_pb.MenuCategoryDeleted) *EventMenuCategoryDeleted
func (*EventMenuCategoryDeleted) AggregateID ¶
func (e *EventMenuCategoryDeleted) AggregateID() string
func (*EventMenuCategoryDeleted) Data ¶
func (e *EventMenuCategoryDeleted) Data() bson.M
func (*EventMenuCategoryDeleted) EventCategory ¶
func (e *EventMenuCategoryDeleted) EventCategory() string
func (*EventMenuCategoryDeleted) EventType ¶
func (e *EventMenuCategoryDeleted) EventType() string
func (*EventMenuCategoryDeleted) ToProto ¶
func (e *EventMenuCategoryDeleted) ToProto() proto.Message
type EventMenuCategoryUpdated ¶
type EventMenuCategoryUpdated struct { ID string `bson:"id,omitempty" json:"id,omitempty"` RestaurantID string `bson:"restaurant_id,omitempty" json:"restaurant_id,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` }
func EventMenuCategoryUpdatedFromData ¶
func EventMenuCategoryUpdatedFromData(data bson.M) *EventMenuCategoryUpdated
func EventMenuCategoryUpdatedFromProto ¶
func EventMenuCategoryUpdatedFromProto(cmd *restaurant_pb.MenuCategoryUpdated) *EventMenuCategoryUpdated
func (*EventMenuCategoryUpdated) AggregateID ¶
func (e *EventMenuCategoryUpdated) AggregateID() string
func (*EventMenuCategoryUpdated) Data ¶
func (e *EventMenuCategoryUpdated) Data() bson.M
func (*EventMenuCategoryUpdated) EventCategory ¶
func (e *EventMenuCategoryUpdated) EventCategory() string
func (*EventMenuCategoryUpdated) EventType ¶
func (e *EventMenuCategoryUpdated) EventType() string
func (*EventMenuCategoryUpdated) ToProto ¶
func (e *EventMenuCategoryUpdated) ToProto() proto.Message
type EventMenuItemCreated ¶
type EventMenuItemCreated struct { ID string `bson:"id,omitempty" json:"id,omitempty"` RestaurantID string `bson:"restaurant_id,omitempty" json:"restaurant_id,omitempty"` CategoryID string `bson:"category_id,omitempty" json:"category_id,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` Description string `bson:"description,omitempty" json:"description,omitempty"` }
func EventMenuItemCreatedFromData ¶
func EventMenuItemCreatedFromData(data bson.M) *EventMenuItemCreated
func EventMenuItemCreatedFromProto ¶
func EventMenuItemCreatedFromProto(cmd *restaurant_pb.MenuItemCreated) *EventMenuItemCreated
func (*EventMenuItemCreated) AggregateID ¶
func (e *EventMenuItemCreated) AggregateID() string
func (*EventMenuItemCreated) Data ¶
func (e *EventMenuItemCreated) Data() bson.M
func (*EventMenuItemCreated) EventCategory ¶
func (e *EventMenuItemCreated) EventCategory() string
func (*EventMenuItemCreated) EventType ¶
func (e *EventMenuItemCreated) EventType() string
func (*EventMenuItemCreated) ToProto ¶
func (e *EventMenuItemCreated) ToProto() proto.Message
type EventMenuItemDeleted ¶
type EventMenuItemDeleted struct { ID string `bson:"id,omitempty" json:"id,omitempty"` RestaurantID string `bson:"restaurant_id,omitempty" json:"restaurant_id,omitempty"` CategoryID string `bson:"category_id,omitempty" json:"category_id,omitempty"` }
func EventMenuItemDeletedFromData ¶
func EventMenuItemDeletedFromData(data bson.M) *EventMenuItemDeleted
func EventMenuItemDeletedFromProto ¶
func EventMenuItemDeletedFromProto(cmd *restaurant_pb.MenuItemDeleted) *EventMenuItemDeleted
func (*EventMenuItemDeleted) AggregateID ¶
func (e *EventMenuItemDeleted) AggregateID() string
func (*EventMenuItemDeleted) Data ¶
func (e *EventMenuItemDeleted) Data() bson.M
func (*EventMenuItemDeleted) EventCategory ¶
func (e *EventMenuItemDeleted) EventCategory() string
func (*EventMenuItemDeleted) EventType ¶
func (e *EventMenuItemDeleted) EventType() string
func (*EventMenuItemDeleted) ToProto ¶
func (e *EventMenuItemDeleted) ToProto() proto.Message
type EventMenuItemUpdated ¶
type EventMenuItemUpdated struct { ID string `bson:"id,omitempty" json:"id,omitempty"` RestaurantID string `bson:"restaurant_id,omitempty" json:"restaurant_id,omitempty"` CategoryID string `bson:"category_id,omitempty" json:"category_id,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` Description string `bson:"description,omitempty" json:"description,omitempty"` }
func EventMenuItemUpdatedFromData ¶
func EventMenuItemUpdatedFromData(data bson.M) *EventMenuItemUpdated
func EventMenuItemUpdatedFromProto ¶
func EventMenuItemUpdatedFromProto(cmd *restaurant_pb.MenuItemUpdated) *EventMenuItemUpdated
func (*EventMenuItemUpdated) AggregateID ¶
func (e *EventMenuItemUpdated) AggregateID() string
func (*EventMenuItemUpdated) Data ¶
func (e *EventMenuItemUpdated) Data() bson.M
func (*EventMenuItemUpdated) EventCategory ¶
func (e *EventMenuItemUpdated) EventCategory() string
func (*EventMenuItemUpdated) EventType ¶
func (e *EventMenuItemUpdated) EventType() string
func (*EventMenuItemUpdated) ToProto ¶
func (e *EventMenuItemUpdated) ToProto() proto.Message
type EventUpdated ¶
type EventUpdated struct { ID string `bson:"id,omitempty" json:"id,omitempty"` Name string `bson:"name,omitempty" json:"name,omitempty"` }
func EventUpdatedFromData ¶
func EventUpdatedFromData(data bson.M) *EventUpdated
func EventUpdatedFromProto ¶
func EventUpdatedFromProto(cmd *restaurant_pb.RestaurantUpdated) *EventUpdated
func (*EventUpdated) AggregateID ¶
func (e *EventUpdated) AggregateID() string
func (*EventUpdated) Data ¶
func (e *EventUpdated) Data() bson.M
func (*EventUpdated) EventCategory ¶
func (e *EventUpdated) EventCategory() string
func (*EventUpdated) EventType ¶
func (e *EventUpdated) EventType() string
func (*EventUpdated) ToProto ¶
func (e *EventUpdated) ToProto() proto.Message
type MenuCategory ¶
type MenuCategory struct { ID string `gorm:"primaryKey" bson:"_id"` RestaurantID string `gorm:"not null" bson:"restaurant_id"` Name string `gorm:"not null;uniqueIndex" bson:"name"` Items []MenuItem `bson:"items"` }
func (*MenuCategory) ToProto ¶
func (mc *MenuCategory) ToProto() *restaurant_pb.MenuCategory
type MenuItem ¶
type MenuItem struct { ID string `gorm:"primaryKey" bson:"_id"` MenuCategoryID string `gorm:"not null" bson:"category_id"` Name string `gorm:"not null;uniqueIndex" bson:"name"` Description string `gorm:"null" bson:"description"` }
func NewMenuItemFromProto ¶
func NewMenuItemFromProto(mi *restaurant_pb.MenuItem) *MenuItem
func (*MenuItem) ToProto ¶
func (mi *MenuItem) ToProto() *restaurant_pb.MenuItem
type QueryService ¶
type QueryService struct { restaurant_pb.UnimplementedQueryServiceServer // contains filtered or unexported fields }
func NewQueryService ¶
func (*QueryService) Close ¶
func (s *QueryService) Close()
func (*QueryService) Get ¶
func (s *QueryService) Get(ctx context.Context, cmd *restaurant_pb.GetRestaurant) (res *restaurant_pb.Restaurant, err error)
func (*QueryService) GetAll ¶
func (s *QueryService) GetAll(ctx context.Context, cmd *restaurant_pb.GetRestaurants) (res *restaurant_pb.Restaurants, err error)
type ReadRepository ¶
type ReadRepository struct { *repository.Base // contains filtered or unexported fields }
func NewReadRepository ¶
func (*ReadRepository) Get ¶
func (repo *ReadRepository) Get(ctx context.Context, id string) (restaurant *Restaurant, err error)
func (*ReadRepository) GetAll ¶
func (repo *ReadRepository) GetAll(ctx context.Context) (restaurants []*Restaurant, err error)
type Restaurant ¶
type Restaurant struct { ID string `gorm:"primaryKey" bson:"_id"` Name string `gorm:"not null;uniqueIndex" bson:"name"` DeletedAt time.Time `gorm:"-" bson:"deleted_at"` MenuCategories []MenuCategory `bson:"menu_categories,omitempty"` }
func NewRestaurantFromEvents ¶
func NewRestaurantFromEvents(events []events.Event) (r *Restaurant, err error)
func NewRestaurantFromProto ¶
func NewRestaurantFromProto(r *restaurant_pb.Restaurant) *Restaurant
func (*Restaurant) ApplyEvent ¶
func (r *Restaurant) ApplyEvent(event events.Event)
func (*Restaurant) ToProto ¶
func (r *Restaurant) ToProto() *restaurant_pb.Restaurant
type WriteRepository ¶
type WriteRepository struct { *repository.Base // contains filtered or unexported fields }
func NewWriteRepository ¶
func (*WriteRepository) Create ¶
func (repo *WriteRepository) Create(ctx context.Context, name string) (event *EventCreated, err error)
func (*WriteRepository) CreateMenuCategory ¶
func (repo *WriteRepository) CreateMenuCategory(ctx context.Context, restaurantID, name string) (event *EventMenuCategoryCreated, err error)
func (*WriteRepository) CreateMenuItem ¶
func (repo *WriteRepository) CreateMenuItem(ctx context.Context, restaurantID, categoryID, name, description string) (event *EventMenuItemCreated, err error)
func (*WriteRepository) Delete ¶
func (repo *WriteRepository) Delete(ctx context.Context, id string) (event *EventDeleted, err error)
func (*WriteRepository) DeleteMenuCategory ¶
func (repo *WriteRepository) DeleteMenuCategory(ctx context.Context, id string) (event *EventMenuCategoryDeleted, err error)
func (*WriteRepository) DeleteMenuItem ¶
func (repo *WriteRepository) DeleteMenuItem(ctx context.Context, restaurantID, id string) (event *EventMenuItemDeleted, err error)
func (*WriteRepository) LoadAggregate ¶
func (repo *WriteRepository) LoadAggregate(id string) (aggregate events.AggregateDB, err error)
func (*WriteRepository) SaveEvents ¶
func (*WriteRepository) Update ¶
func (repo *WriteRepository) Update(ctx context.Context, id, name string) (event *EventUpdated, err error)
func (*WriteRepository) UpdateMenuCategory ¶
func (repo *WriteRepository) UpdateMenuCategory(ctx context.Context, id, name string) (event *EventMenuCategoryUpdated, err error)
func (*WriteRepository) UpdateMenuItem ¶
func (repo *WriteRepository) UpdateMenuItem(ctx context.Context, restaurantID, categoryID, id, name, description string) (event *EventMenuItemUpdated, err error)
Click to show internal directories.
Click to hide internal directories.