liveBook · Manning

State transition

As explained in Build and Orchestrator in Go (From Scratch)

A state transition is a change of a task from one lifecycle state to another in response to an event.

A state transition moves a task from one lifecycle state to another when an event occurs. Modeling transitions explicitly prevents invalid moves, such as sending a running task back to scheduled or restarting a failed task. section 4.6.3

Table 4.1 State transition table showing the valid transitions from one state to another (view table figure)

CurrentState

Event

NextState

Pending

ScheduleEvent

Scheduled

Pending

ScheduleEvent

Failed

Scheduled

StartTask

Running

Scheduled

StartTask

Failed

Running

StopTask

Completed

Use the transition table to connect current state, triggering event, and next state before encoding the rules. section 4.6.3

How Build and Orchestrator in Go (From Scratch) covers it

How deep it goes
Defines states, tabulates valid moves, and implements map-based validation while deferring a full state-machine abstraction.
Examples
Uses Pending, Scheduled, Running, Completed, and Failed states with ScheduleEvent, StartTask, and StopTask transitions.
What it assumes
Assumes task states and lifecycle events; teaches how to specify and validate their permitted transitions.
What you can do after
Build it from scratch with a state map and helper that reject destinations not listed for the current state.
How it connects
Connects task lifecycle states with events, state machines, and orchestration systems.

Also explained in

Compare how 7 books explain state transition →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build and Orchestrator in Go (From Scratch). The section links point to the parts of the book it draws on.