Stock

@Description(value = "A product's stock: units on hand, and those reserved for orders")
class Stock(state: StockState)

A product's stock; its id is the product's id. The ordering context reserves units here for each order awaiting validation, commits the reservation once the order is shipped and releases it once the order is cancelled. Those commands come from another context, through this context's command topic.

A short stock is a rejection (Rejections.INSUFFICIENT): nothing is written, and the rejection goes back to the ordering saga that sent the reservation, as a receipt. Every command for one order is idempotent by the order's id, besides the kernel's de-duplication by request id: reserving again for an order already reserved, and releasing a reservation that is not there, change nothing.

A product's stock belongs to its tenant (Ownership.TENANT): the order-process saga reserves it in the scope of the buyer whose order it handles, which the stock does not check.

Constructors

Link copied to clipboard
constructor(state: StockState)

Types

Link copied to clipboard
object Rejections

The codes the aggregate rejects a command with, by their local names: the compiler and the kernel name them <context>.stock.<code>, as its peers read them from the api's generated contract.

Functions

Link copied to clipboard

Releasing a reservation the order does not hold changes nothing: that product may be the one that was short.

Commits the order's reservation. Nothing reserved for the order is a rejection: a shipped order was reserved.