orders

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventOrderCreated

type EventOrderCreated struct {
	ID         string
	Restaurant *restaurant.Restaurant
	Items      []*restaurant.MenuItem
	Status     string
}

func EventOrderCreatedFromData

func EventOrderCreatedFromData(data bson.M) *EventOrderCreated

func EventOrderCreatedFromProto

func EventOrderCreatedFromProto(cmd *orders_pb.OrderCreated) *EventOrderCreated

func (*EventOrderCreated) AggregateID

func (e *EventOrderCreated) AggregateID() string

func (*EventOrderCreated) Data

func (e *EventOrderCreated) Data() bson.M

func (*EventOrderCreated) EventCategory

func (e *EventOrderCreated) EventCategory() string

func (*EventOrderCreated) EventType

func (e *EventOrderCreated) EventType() string

func (*EventOrderCreated) ToProto

func (e *EventOrderCreated) ToProto() proto.Message

type EventStatusUpdated

type EventStatusUpdated struct {
	ID     string
	Status string
}

func EventStatusUpdatedFromData

func EventStatusUpdatedFromData(data bson.M) *EventStatusUpdated

func EventStatusUpdatedFromProto

func EventStatusUpdatedFromProto(cmd *orders_pb.StatusUpdated) *EventStatusUpdated

func (*EventStatusUpdated) AggregateID

func (e *EventStatusUpdated) AggregateID() string

func (*EventStatusUpdated) Data

func (e *EventStatusUpdated) Data() bson.M

func (*EventStatusUpdated) EventCategory

func (e *EventStatusUpdated) EventCategory() string

func (*EventStatusUpdated) EventType

func (e *EventStatusUpdated) EventType() string

func (*EventStatusUpdated) ToProto

func (e *EventStatusUpdated) ToProto() proto.Message

type Order

type Order struct {
	ID         string                 `bson:"_id"`
	Status     string                 `bson:"status"`
	Restaurant *restaurant.Restaurant `bson:"restaurant"`
	Items      []*restaurant.MenuItem `bson:"items"`
}

func NewFromEvents

func NewFromEvents(events []events.Event) (s *Order)

func (*Order) ApplyEvent

func (s *Order) ApplyEvent(event events.Event)

type Repository

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

func NewRepository

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

func (*Repository) CreateOrder

func (repo *Repository) CreateOrder(ctx context.Context, restaurant *restaurant.Restaurant, items []*restaurant.MenuItem) (event *EventOrderCreated, err error)

func (*Repository) LoadAggregate

func (repo *Repository) LoadAggregate(id string) (aggregate events.AggregateDB, err error)

func (*Repository) SaveEvents

func (repo *Repository) SaveEvents(aggregateID string, aggregateEvents []events.Event, originalVersion int) (err error)

func (*Repository) UpdateStatus

func (repo *Repository) UpdateStatus(ctx context.Context, id string, status *orders_pb.OrderStatus) (event *EventStatusUpdated, err error)

type Service

type Service struct {
	orders_pb.UnimplementedOrdersServiceServer
	// contains filtered or unexported fields
}

func NewService

func NewService(restaurantQueryService *restaurant.QueryService, stockService *stock.Service, nec *nats.EncodedConn, mongo *mongo.Database, metricsRegistry *metrics.Registry, appStatus *status.Status, log zerolog.Logger) (c *Service, err error)

func (*Service) Close

func (s *Service) Close()

func (*Service) Create

func (s *Service) Create(ctx context.Context, cmd *orders_pb.CmdCreateOrder) (event *orders_pb.OrderCreated, err error)

func (*Service) UpdateStatus

func (s *Service) UpdateStatus(ctx context.Context, cmd *orders_pb.CmdUpdateStatus) (res *orders_pb.StatusUpdated, err error)

Jump to

Keyboard shortcuts

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