stock

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventStockDecreased

type EventStockDecreased struct {
	ItemID string `bson:"item_id,omitempty" json:"item_id,omitempty"`
	N      int32  `bson:"n,omitempty" json:"n,omitempty"`
}

func EventStockDecreasedFromData

func EventStockDecreasedFromData(data bson.M) *EventStockDecreased

func EventStockDecreasedFromProto

func EventStockDecreasedFromProto(cmd *stock_pb.StockDecreased) *EventStockDecreased

func (*EventStockDecreased) AggregateID

func (e *EventStockDecreased) AggregateID() string

func (*EventStockDecreased) Data

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

func (*EventStockDecreased) EventCategory

func (e *EventStockDecreased) EventCategory() string

func (*EventStockDecreased) EventType

func (e *EventStockDecreased) EventType() string

func (*EventStockDecreased) ToProto

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

type EventStockIncreased

type EventStockIncreased struct {
	ItemID string `bson:"item_id,omitempty" json:"item_id,omitempty"`
	N      int32  `bson:"n,omitempty" json:"n,omitempty"`
}

func EventStockIncreasedFromData

func EventStockIncreasedFromData(data bson.M) *EventStockIncreased

func EventStockIncreasedFromProto

func EventStockIncreasedFromProto(cmd *stock_pb.StockIncreased) *EventStockIncreased

func (*EventStockIncreased) AggregateID

func (e *EventStockIncreased) AggregateID() string

func (*EventStockIncreased) Data

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

func (*EventStockIncreased) EventCategory

func (e *EventStockIncreased) EventCategory() string

func (*EventStockIncreased) EventType

func (e *EventStockIncreased) EventType() string

func (*EventStockIncreased) ToProto

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

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) DecreaseStock

func (repo *Repository) DecreaseStock(ctx context.Context, itemID string, n int32) (event *EventStockDecreased, err error)

func (*Repository) IncreaseStock

func (repo *Repository) IncreaseStock(ctx context.Context, itemID string, n int32) (event *EventStockIncreased, 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)

type Service

type Service struct {
	stock_pb.UnimplementedStockServiceServer
	// contains filtered or unexported fields
}

func NewService

func NewService(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) DecreaseStock

func (s *Service) DecreaseStock(ctx context.Context, cmd *stock_pb.CmdDecreaseStock) (res *stock_pb.StockDecreased, err error)

func (*Service) IncreaseStock

func (s *Service) IncreaseStock(ctx context.Context, cmd *stock_pb.CmdIncreaseStock) (res *stock_pb.StockIncreased, err error)

type Stock

type Stock struct {
	ItemID string `bson:"_id,omitempty" json:"item_id,omitempty"`
	N      int32  `bson:"n" json:"n"`
}

func NewFromEvents

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

func (*Stock) ApplyEvent

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

Jump to

Keyboard shortcuts

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