Documentation
¶
Index ¶
- Constants
- Variables
- type CatalogProduct
- type CatalogRepository
- type FakeCatalogRepository
- func (r *FakeCatalogRepository) AddProduct(ctx context.Context, productID, storeID, name, description, sku string, ...) error
- func (r *FakeCatalogRepository) Find(ctx context.Context, productID string) (*CatalogProduct, error)
- func (r *FakeCatalogRepository) GetCatalog(ctx context.Context, storeID string) ([]*CatalogProduct, error)
- func (r *FakeCatalogRepository) Rebrand(ctx context.Context, productID, name, description string) error
- func (r *FakeCatalogRepository) RemoveProduct(ctx context.Context, productID string) error
- func (r *FakeCatalogRepository) UpdatePrice(ctx context.Context, productID string, delta float64) error
- type FakeMallRepository
- func (r *FakeMallRepository) AddStore(ctx context.Context, storeID, name, location string) error
- func (r *FakeMallRepository) All(ctx context.Context) ([]*MallStore, error)
- func (r *FakeMallRepository) AllParticipating(ctx context.Context) ([]*MallStore, error)
- func (r *FakeMallRepository) Find(ctx context.Context, storeID string) (*MallStore, error)
- func (r *FakeMallRepository) RenameStore(ctx context.Context, storeID, name string) error
- func (r *FakeMallRepository) SetStoreParticipation(ctx context.Context, storeID string, participating bool) error
- type FakeProductRepository
- type FakeStoreRepository
- type MallRepository
- type MallStore
- type MockCatalogRepository
- func (_m *MockCatalogRepository) AddProduct(ctx context.Context, productID string, storeID string, name string, ...) error
- func (_m *MockCatalogRepository) Find(ctx context.Context, productID string) (*CatalogProduct, error)
- func (_m *MockCatalogRepository) GetCatalog(ctx context.Context, storeID string) ([]*CatalogProduct, error)
- func (_m *MockCatalogRepository) Rebrand(ctx context.Context, productID string, name string, description string) error
- func (_m *MockCatalogRepository) RemoveProduct(ctx context.Context, productID string) error
- func (_m *MockCatalogRepository) UpdatePrice(ctx context.Context, productID string, delta float64) error
- type MockMallRepository
- func (_m *MockMallRepository) AddStore(ctx context.Context, storeID string, name string, location string) error
- func (_m *MockMallRepository) All(ctx context.Context) ([]*MallStore, error)
- func (_m *MockMallRepository) AllParticipating(ctx context.Context) ([]*MallStore, error)
- func (_m *MockMallRepository) Find(ctx context.Context, storeID string) (*MallStore, error)
- func (_m *MockMallRepository) RenameStore(ctx context.Context, storeID string, name string) error
- func (_m *MockMallRepository) SetStoreParticipation(ctx context.Context, storeID string, participating bool) error
- type MockProductRepository
- type MockStoreRepository
- type Product
- func (p *Product) ApplyEvent(event ddd.Event) error
- func (p *Product) ApplySnapshot(snapshot es.Snapshot) error
- func (p *Product) DecreasePrice(price float64) (ddd.Event, error)
- func (p *Product) IncreasePrice(price float64) (ddd.Event, error)
- func (p *Product) InitProduct(id, storeID, name, description, sku string, price float64) (ddd.Event, error)
- func (Product) Key() string
- func (p *Product) Rebrand(name, description string) (ddd.Event, error)
- func (p *Product) Remove() (ddd.Event, error)
- func (p Product) ToSnapshot() es.Snapshot
- type ProductAdded
- type ProductPriceChanged
- type ProductPriceDelta
- 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() (ddd.Event, error)
- func (s *Store) EnableParticipation() (ddd.Event, error)
- func (s *Store) InitStore(name, location string) (ddd.Event, error)
- func (Store) Key() string
- func (s *Store) Rebrand(name string) (ddd.Event, error)
- func (s Store) ToSnapshot() es.Snapshot
- type StoreCreated
- type StoreParticipationToggled
- type StoreRebranded
- type StoreRepository
- type StoreV1
Constants ¶
const ( ProductAddedEvent = "stores.ProductAdded" ProductRebrandedEvent = "stores.ProductRebranded" ProductPriceIncreasedEvent = "stores.ProductPriceIncreased" ProductPriceDecreasedEvent = "stores.ProductPriceDecreased" ProductRemovedEvent = "stores.ProductRemoved" )
const ( StoreCreatedEvent = "stores.StoreCreated" StoreParticipationEnabledEvent = "stores.StoreParticipationEnabled" StoreParticipationDisabledEvent = "stores.StoreParticipationDisabled" StoreRebrandedEvent = "stores.StoreRebranded" )
const ProductAggregate = "stores.Product"
const StoreAggregate = "stores.Store"
Variables ¶
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") )
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 FakeCatalogRepository ¶
type FakeCatalogRepository struct {
// contains filtered or unexported fields
}
func NewFakeCatalogRepository ¶
func NewFakeCatalogRepository() *FakeCatalogRepository
func (*FakeCatalogRepository) AddProduct ¶
func (*FakeCatalogRepository) Find ¶
func (r *FakeCatalogRepository) Find(ctx context.Context, productID string) (*CatalogProduct, error)
func (*FakeCatalogRepository) GetCatalog ¶
func (r *FakeCatalogRepository) GetCatalog(ctx context.Context, storeID string) ([]*CatalogProduct, error)
func (*FakeCatalogRepository) Rebrand ¶
func (r *FakeCatalogRepository) Rebrand(ctx context.Context, productID, name, description string) error
func (*FakeCatalogRepository) RemoveProduct ¶
func (r *FakeCatalogRepository) RemoveProduct(ctx context.Context, productID string) error
func (*FakeCatalogRepository) UpdatePrice ¶
type FakeMallRepository ¶
type FakeMallRepository struct {
// contains filtered or unexported fields
}
func NewFakeMallRepository ¶
func NewFakeMallRepository() *FakeMallRepository
func (*FakeMallRepository) AddStore ¶
func (r *FakeMallRepository) AddStore(ctx context.Context, storeID, name, location string) error
func (*FakeMallRepository) All ¶
func (r *FakeMallRepository) All(ctx context.Context) ([]*MallStore, error)
func (*FakeMallRepository) AllParticipating ¶
func (r *FakeMallRepository) AllParticipating(ctx context.Context) ([]*MallStore, error)
func (*FakeMallRepository) RenameStore ¶
func (r *FakeMallRepository) RenameStore(ctx context.Context, storeID, name string) error
func (*FakeMallRepository) SetStoreParticipation ¶
type FakeProductRepository ¶
type FakeProductRepository struct {
// contains filtered or unexported fields
}
func NewFakeProductRepository ¶
func NewFakeProductRepository() *FakeProductRepository
func (*FakeProductRepository) Reset ¶
func (r *FakeProductRepository) Reset(products ...*Product)
type FakeStoreRepository ¶
type FakeStoreRepository struct {
// contains filtered or unexported fields
}
func NewFakeStoreRepository ¶
func NewFakeStoreRepository() *FakeStoreRepository
func (*FakeStoreRepository) Reset ¶
func (r *FakeStoreRepository) Reset(stores ...*Store)
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 MockCatalogRepository ¶
MockCatalogRepository is an autogenerated mock type for the CatalogRepository type
func NewMockCatalogRepository ¶
func NewMockCatalogRepository(t mockConstructorTestingTNewMockCatalogRepository) *MockCatalogRepository
NewMockCatalogRepository creates a new instance of MockCatalogRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockCatalogRepository) AddProduct ¶
func (_m *MockCatalogRepository) AddProduct(ctx context.Context, productID string, storeID string, name string, description string, sku string, price float64) error
AddProduct provides a mock function with given fields: ctx, productID, storeID, name, description, sku, price
func (*MockCatalogRepository) Find ¶
func (_m *MockCatalogRepository) Find(ctx context.Context, productID string) (*CatalogProduct, error)
Find provides a mock function with given fields: ctx, productID
func (*MockCatalogRepository) GetCatalog ¶
func (_m *MockCatalogRepository) GetCatalog(ctx context.Context, storeID string) ([]*CatalogProduct, error)
GetCatalog provides a mock function with given fields: ctx, storeID
func (*MockCatalogRepository) Rebrand ¶
func (_m *MockCatalogRepository) Rebrand(ctx context.Context, productID string, name string, description string) error
Rebrand provides a mock function with given fields: ctx, productID, name, description
func (*MockCatalogRepository) RemoveProduct ¶
func (_m *MockCatalogRepository) RemoveProduct(ctx context.Context, productID string) error
RemoveProduct provides a mock function with given fields: ctx, productID
func (*MockCatalogRepository) UpdatePrice ¶
func (_m *MockCatalogRepository) UpdatePrice(ctx context.Context, productID string, delta float64) error
UpdatePrice provides a mock function with given fields: ctx, productID, delta
type MockMallRepository ¶
MockMallRepository is an autogenerated mock type for the MallRepository type
func NewMockMallRepository ¶
func NewMockMallRepository(t mockConstructorTestingTNewMockMallRepository) *MockMallRepository
NewMockMallRepository creates a new instance of MockMallRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockMallRepository) AddStore ¶
func (_m *MockMallRepository) AddStore(ctx context.Context, storeID string, name string, location string) error
AddStore provides a mock function with given fields: ctx, storeID, name, location
func (*MockMallRepository) All ¶
func (_m *MockMallRepository) All(ctx context.Context) ([]*MallStore, error)
All provides a mock function with given fields: ctx
func (*MockMallRepository) AllParticipating ¶
func (_m *MockMallRepository) AllParticipating(ctx context.Context) ([]*MallStore, error)
AllParticipating provides a mock function with given fields: ctx
func (*MockMallRepository) RenameStore ¶
RenameStore provides a mock function with given fields: ctx, storeID, name
func (*MockMallRepository) SetStoreParticipation ¶
func (_m *MockMallRepository) SetStoreParticipation(ctx context.Context, storeID string, participating bool) error
SetStoreParticipation provides a mock function with given fields: ctx, storeID, participating
type MockProductRepository ¶
MockProductRepository is an autogenerated mock type for the ProductRepository type
func NewMockProductRepository ¶
func NewMockProductRepository(t mockConstructorTestingTNewMockProductRepository) *MockProductRepository
NewMockProductRepository creates a new instance of MockProductRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
type MockStoreRepository ¶
MockStoreRepository is an autogenerated mock type for the StoreRepository type
func NewMockStoreRepository ¶
func NewMockStoreRepository(t mockConstructorTestingTNewMockStoreRepository) *MockStoreRepository
NewMockStoreRepository creates a new instance of MockStoreRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
type Product ¶
type Product struct { es.Aggregate StoreID string Name string Description string SKU string Price float64 }
func NewProduct ¶
func (*Product) InitProduct ¶
func (Product) ToSnapshot ¶
type ProductAdded ¶
type ProductPriceChanged ¶
type ProductPriceChanged struct {
Delta float64
}
type ProductPriceDelta ¶
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 (*Store) ApplyEvent ¶
ApplyEvent implements es.EventApplier
func (*Store) ApplySnapshot ¶
ApplySnapshot implements es.Snapshotter
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 ¶
Source Files
¶
- catalog_repository.go
- fake_catalog_repository.go
- fake_mall_repository.go
- fake_product_repository.go
- fake_store_repository.go
- mall_repository.go
- mock_catalog_repository.go
- mock_mall_repository.go
- mock_product_repository.go
- mock_store_repository.go
- product.go
- product_events.go
- product_repository.go
- product_snapshots.go
- store.go
- store_events.go
- store_repository.go
- store_snapshots.go