restaurant

package
v0.0.0-...-5dae249 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: Unlicense Imports: 17 Imported by: 0

Documentation

Index

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 NewCommandService(nec *nats.EncodedConn, db *gorm.DB, mongo *mongo.Database, metricsRegistry *metrics.Registry, appStatus *status.Status, log zerolog.Logger) (c *CommandService, err error)

func (*CommandService) Close

func (s *CommandService) Close()

func (*CommandService) Create

func (*CommandService) CreateMenuCategory

func (*CommandService) CreateMenuItem

func (*CommandService) Delete

func (*CommandService) DeleteMenuCategory

func (*CommandService) DeleteMenuItem

func (*CommandService) Update

func (*CommandService) UpdateMenuCategory

func (*CommandService) UpdateMenuItem

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 (*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 (*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 (*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 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 (mc *MenuCategory) ToProto() *restaurant_pb.MenuCategory
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 (mi *MenuItem) ToProto() *restaurant_pb.MenuItem

type QueryService

type QueryService struct {
	restaurant_pb.UnimplementedQueryServiceServer
	// contains filtered or unexported fields
}

func NewQueryService

func NewQueryService(nec *nats.EncodedConn, mongoDB *mongo.Database, metricsRegistry *metrics.Registry, appStatus *status.Status, log zerolog.Logger) (c *QueryService, err error)

func (*QueryService) Close

func (s *QueryService) Close()

func (*QueryService) Get

func (*QueryService) GetAll

type ReadRepository

type ReadRepository struct {
	*repository.Base
	// contains filtered or unexported fields
}

func NewReadRepository

func NewReadRepository(nc *nats.EncodedConn, mongoDB *mongo.Database, log zerolog.Logger) (repo *ReadRepository, err error)

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 NewWriteRepository(nc *nats.EncodedConn, db *gorm.DB, mongo *mongo.Database, log zerolog.Logger) (repo *WriteRepository, err error)

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 (repo *WriteRepository) SaveEvents(aggregateID string, aggregateEvents []events.Event, originalVersion int) (err error)

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)

Jump to

Keyboard shortcuts

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