Documentation ¶
Index ¶
- Constants
- Variables
- type CatalogProduct
- type CatalogRepository
- type MallRepository
- type MallStore
- type Product
- func (p *Product) ApplyEvent(event ddd.Event) error
- func (p *Product) ApplySnapshot(snapshot es.Snapshot) error
- func (p *Product) DecreasePrice(price float64) error
- func (p *Product) IncreasePrice(price float64) error
- func (Product) Key() string
- func (p *Product) Rebrand(name, description string) error
- func (p *Product) Remove() error
- func (p Product) ToSnapshot() es.Snapshot
- type ProductAdded
- type ProductPriceChanged
- type ProductRebranded
- type ProductRemoved
- type ProductRepository
- type ProductV1
- type Store
- func (s *Store) ApplyEvent(event ddd.Event) error
- func (s *Store) ApplySnapshot(snapshot es.Snapshot) error
- func (s *Store) DisableParticipation() (err error)
- func (s *Store) EnableParticipation() (err error)
- func (Store) Key() string
- func (s *Store) Rebrand(name string) error
- func (s Store) ToSnapshot() es.Snapshot
- type StoreCreated
- type StoreParticipationToggled
- type StoreRebranded
- type StoreRepository
- type StoreV1
Constants ¶
View Source
const ( ProductAddedEvent = "stores.ProductAdded" ProductRebrandedEvent = "stores.ProductRebranded" ProductPriceIncreasedEvent = "stores.ProductPriceIncreased" ProductPriceDecreasedEvent = "stores.ProductPriceDecreased" ProductRemovedEvent = "stores.ProductRemoved" )
View Source
const ( StoreCreatedEvent = "stores.StoreCreated" StoreParticipationEnabledEvent = "stores.StoreParticipationEnabled" StoreParticipationDisabledEvent = "stores.StoreParticipationDisabled" StoreRebrandedEvent = "stores.StoreRebranded" )
View Source
const ProductAggregate = "stores.Product"
View Source
const StoreAggregate = "stores.Store"
Variables ¶
View Source
var ( ErrProductNameIsBlank = errors.Wrap(errors.ErrBadRequest, "the product name cannot be blank") ErrProductPriceIsNegative = errors.Wrap(errors.ErrBadRequest, "the product price cannot be negative") ErrNotAPriceIncrease = errors.Wrap(errors.ErrBadRequest, "the price change would be a decrease") ErrNotAPriceDecrease = errors.Wrap(errors.ErrBadRequest, "the price change would be an increase") )
View Source
var ( ErrStoreNameIsBlank = errors.Wrap(errors.ErrBadRequest, "the store name cannot be blank") ErrStoreLocationIsBlank = errors.Wrap(errors.ErrBadRequest, "the store location cannot be blank") ErrStoreIsAlreadyParticipating = errors.Wrap(errors.ErrBadRequest, "the store is already participating") ErrStoreIsAlreadyNotParticipating = errors.Wrap(errors.ErrBadRequest, "the store is already not participating") )
Functions ¶
This section is empty.
Types ¶
type CatalogProduct ¶
type CatalogRepository ¶
type CatalogRepository interface { AddProduct(ctx context.Context, productID, storeID, name, description, sku string, price float64) error Rebrand(ctx context.Context, productID, name, description string) error UpdatePrice(ctx context.Context, productID string, delta float64) error RemoveProduct(ctx context.Context, productID string) error Find(ctx context.Context, productID string) (*CatalogProduct, error) GetCatalog(ctx context.Context, storeID string) ([]*CatalogProduct, error) }
type MallRepository ¶
type MallRepository interface { AddStore(ctx context.Context, storeID, name, location string) error SetStoreParticipation(ctx context.Context, storeID string, participating bool) error RenameStore(ctx context.Context, storeID, name string) error Find(ctx context.Context, storeID string) (*MallStore, error) All(ctx context.Context) ([]*MallStore, error) AllParticipating(ctx context.Context) ([]*MallStore, error) }
type Product ¶
type Product struct { es.Aggregate StoreID string Name string Description string SKU string Price float64 }
func CreateProduct ¶
func NewProduct ¶
func (*Product) DecreasePrice ¶
func (*Product) IncreasePrice ¶
func (Product) ToSnapshot ¶
type ProductAdded ¶
type ProductPriceChanged ¶
type ProductPriceChanged struct {
Delta float64
}
type ProductRebranded ¶
func (ProductRebranded) Key ¶
func (ProductRebranded) Key() string
Key implements registry.Registerable
type ProductRemoved ¶
type ProductRemoved struct{}
type ProductRepository ¶
type ProductV1 ¶
func (ProductV1) SnapshotName ¶
type Store ¶
func CreateStore ¶
func (*Store) ApplyEvent ¶
ApplyEvent implements es.EventApplier
func (*Store) ApplySnapshot ¶
ApplySnapshot implements es.Snapshotter
func (*Store) DisableParticipation ¶
func (*Store) EnableParticipation ¶
func (Store) ToSnapshot ¶
ToSnapshot implements es.Snapshotter
type StoreCreated ¶
type StoreParticipationToggled ¶
type StoreParticipationToggled struct {
Participating bool
}
type StoreRebranded ¶
type StoreRebranded struct {
Name string
}
type StoreRepository ¶
Click to show internal directories.
Click to hide internal directories.