inventory

package
v0.0.0-...-6bf1803 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inventory

type Inventory struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Inventory represents methods to manage the inventory

func New

func New(store UnderlyingStore) *Inventory

New returns a new instance of inventory

func (*Inventory) GetPrice

func (i *Inventory) GetPrice(productID uint) (uint, error)

GetPrice returns the price of a product

func (*Inventory) GetProductStock

func (i *Inventory) GetProductStock(id uint) (uint, error)

GetProductStock returns the stock of a item given the ID

func (*Inventory) HasInStock

func (i *Inventory) HasInStock(id uint, quantity uint) (bool, error)

HasInStock check if enough stock of a product is still present

func (*Inventory) RemoveFromStock

func (i *Inventory) RemoveFromStock(items map[uint]uint, commitChan <-chan bool, errorChan chan<- error) error

RemoveFromStock removes the requested quantity for each product from stock Blocks until the stock is verified as suficient. Blocks writing to store until the condition is met

type UnderlyingStore

type UnderlyingStore interface {
	GetProductByID(ID uint) (*store.Product, error)
	SetProducts(products ...*store.Product) (*store.ProductTransaction, error)
}

UnderlyingStore represents the interface the invetory store has to implement

Directories

Path Synopsis
Package mock_inventory is a generated GoMock package.
Package mock_inventory is a generated GoMock package.

Jump to

Keyboard shortcuts

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