State machine
A model where an entity is always in one of a fixed set of states and only listed events move it between them. Written as a transition table (state and event to next state), plus who may fire each event, so the rules live in data instead of scattered conditionals.
Minimal example
var next = map[transition]Status{
{Placed, Accept}: Accepted,
{Placed, Cancel}: Cancelled,
}Learn this concept
Lesson 3.11 · State machines and optimistic lockingUsed in exercises
Exercise 3.12 · POST /v1/orders/{id}/events: order lifecycle Exercise 5.8 · Rider assignment worker Exercise 8.4 · Payment processing serviceRelatedOptimistic locking