domain

package
v0.0.0-...-76fafce Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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 CatalogProduct struct {
	ID          string
	StoreID     string
	Name        string
	Description string
	SKU         string
	Price       float64
}

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 (r *FakeCatalogRepository) AddProduct(ctx context.Context, productID, storeID, name, description, sku string, price float64) error

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

func (r *FakeCatalogRepository) UpdatePrice(ctx context.Context, productID string, delta float64) error

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

func (r *FakeMallRepository) Find(ctx context.Context, storeID string) (*MallStore, error)

func (*FakeMallRepository) RenameStore

func (r *FakeMallRepository) RenameStore(ctx context.Context, storeID, name string) error

func (*FakeMallRepository) SetStoreParticipation

func (r *FakeMallRepository) SetStoreParticipation(ctx context.Context, storeID string, participating bool) error

type FakeProductRepository

type FakeProductRepository struct {
	// contains filtered or unexported fields
}

func NewFakeProductRepository

func NewFakeProductRepository() *FakeProductRepository

func (*FakeProductRepository) Load

func (r *FakeProductRepository) Load(ctx context.Context, productID string) (*Product, error)

func (*FakeProductRepository) Reset

func (r *FakeProductRepository) Reset(products ...*Product)

func (*FakeProductRepository) Save

func (r *FakeProductRepository) Save(ctx context.Context, product *Product) error

type FakeStoreRepository

type FakeStoreRepository struct {
	// contains filtered or unexported fields
}

func NewFakeStoreRepository

func NewFakeStoreRepository() *FakeStoreRepository

func (*FakeStoreRepository) Load

func (r *FakeStoreRepository) Load(ctx context.Context, storeID string) (*Store, error)

func (*FakeStoreRepository) Reset

func (r *FakeStoreRepository) Reset(stores ...*Store)

func (*FakeStoreRepository) Save

func (r *FakeStoreRepository) Save(ctx context.Context, store *Store) 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 MallStore

type MallStore struct {
	ID            string
	Name          string
	Location      string
	Participating bool
}

type MockCatalogRepository

type MockCatalogRepository struct {
	mock.Mock
}

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

type MockMallRepository struct {
	mock.Mock
}

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

func (_m *MockMallRepository) Find(ctx context.Context, storeID string) (*MallStore, error)

Find provides a mock function with given fields: ctx, storeID

func (*MockMallRepository) RenameStore

func (_m *MockMallRepository) RenameStore(ctx context.Context, storeID string, name string) error

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

type MockProductRepository struct {
	mock.Mock
}

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.

func (*MockProductRepository) Load

func (_m *MockProductRepository) Load(ctx context.Context, id string) (*Product, error)

Load provides a mock function with given fields: ctx, id

func (*MockProductRepository) Save

func (_m *MockProductRepository) Save(ctx context.Context, product *Product) error

Save provides a mock function with given fields: ctx, product

type MockStoreRepository

type MockStoreRepository struct {
	mock.Mock
}

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.

func (*MockStoreRepository) Load

func (_m *MockStoreRepository) Load(ctx context.Context, storeID string) (*Store, error)

Load provides a mock function with given fields: ctx, storeID

func (*MockStoreRepository) Save

func (_m *MockStoreRepository) Save(ctx context.Context, store *Store) error

Save provides a mock function with given fields: ctx, store

type Product

type Product struct {
	es.Aggregate
	StoreID     string
	Name        string
	Description string
	SKU         string
	Price       float64
}

func NewProduct

func NewProduct(id string) *Product

func (*Product) ApplyEvent

func (p *Product) ApplyEvent(event ddd.Event) error

func (*Product) ApplySnapshot

func (p *Product) ApplySnapshot(snapshot es.Snapshot) error

func (*Product) DecreasePrice

func (p *Product) DecreasePrice(price float64) (ddd.Event, error)

func (*Product) IncreasePrice

func (p *Product) IncreasePrice(price float64) (ddd.Event, error)

func (*Product) InitProduct

func (p *Product) InitProduct(id, storeID, name, description, sku string, price float64) (ddd.Event, error)

func (Product) Key

func (Product) Key() string

Key implements registry.Registerable

func (*Product) Rebrand

func (p *Product) Rebrand(name, description string) (ddd.Event, error)

func (*Product) Remove

func (p *Product) Remove() (ddd.Event, error)

func (Product) ToSnapshot

func (p Product) ToSnapshot() es.Snapshot

type ProductAdded

type ProductAdded struct {
	StoreID     string
	Name        string
	Description string
	SKU         string
	Price       float64
}

func (ProductAdded) Key

func (ProductAdded) Key() string

Key implements registry.Registerable

type ProductPriceChanged

type ProductPriceChanged struct {
	Delta float64
}

type ProductPriceDelta

type ProductPriceDelta struct {
	Product *Product
	Delta   float64
}

type ProductRebranded

type ProductRebranded struct {
	Name        string
	Description string
}

func (ProductRebranded) Key

func (ProductRebranded) Key() string

Key implements registry.Registerable

type ProductRemoved

type ProductRemoved struct{}

func (ProductRemoved) Key

func (ProductRemoved) Key() string

Key implements registry.Registerable

type ProductRepository

type ProductRepository interface {
	Load(ctx context.Context, id string) (*Product, error)
	Save(ctx context.Context, product *Product) error
}

type ProductV1

type ProductV1 struct {
	StoreID     string
	Name        string
	Description string
	SKU         string
	Price       float64
}

func (ProductV1) SnapshotName

func (ProductV1) SnapshotName() string

type Store

type Store struct {
	es.Aggregate
	Name          string
	Location      string
	Participating bool
}

func NewStore

func NewStore(id string) *Store

func (*Store) ApplyEvent

func (s *Store) ApplyEvent(event ddd.Event) error

ApplyEvent implements es.EventApplier

func (*Store) ApplySnapshot

func (s *Store) ApplySnapshot(snapshot es.Snapshot) error

ApplySnapshot implements es.Snapshotter

func (*Store) DisableParticipation

func (s *Store) DisableParticipation() (ddd.Event, error)

func (*Store) EnableParticipation

func (s *Store) EnableParticipation() (ddd.Event, error)

func (*Store) InitStore

func (s *Store) InitStore(name, location string) (ddd.Event, error)

func (Store) Key

func (Store) Key() string

Key implements registry.Registerable

func (*Store) Rebrand

func (s *Store) Rebrand(name string) (ddd.Event, error)

func (Store) ToSnapshot

func (s Store) ToSnapshot() es.Snapshot

ToSnapshot implements es.Snapshotter

type StoreCreated

type StoreCreated struct {
	Name     string
	Location string
}

func (StoreCreated) Key

func (StoreCreated) Key() string

Key implements registry.Registerable

type StoreParticipationToggled

type StoreParticipationToggled struct {
	Participating bool
}

type StoreRebranded

type StoreRebranded struct {
	Name string
}

func (StoreRebranded) Key

func (StoreRebranded) Key() string

Key implements registry.Registerable

type StoreRepository

type StoreRepository interface {
	Load(ctx context.Context, storeID string) (*Store, error)
	Save(ctx context.Context, store *Store) error
}

type StoreV1

type StoreV1 struct {
	Name          string
	Location      string
	Participating bool
}

func (StoreV1) SnapshotName

func (StoreV1) SnapshotName() string

Jump to

Keyboard shortcuts

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