liveBook · Manning

Pending state

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

The pending state is a task lifecycle state in which a task has not yet entered the scheduling or execution phases.

Pending is the initial task lifecycle state. It begins when a user submits a task and the system enqueues it, before scheduling identifies where it should run. section 2.1 section 4.6.3

A task normally progresses from Pending to Scheduled, then Running, and finally Completed; failures can move it into Failed. Pending therefore represents work accepted by the system but not yet assigned to a worker. section 2.1 section 4.6.3

The state participates in a small, explicit transition model:

  • ScheduleEvent moves a task from Pending to Scheduled. section 4.6.3
  • Pending has no direct transition to Running, Completed, or Failed in the transition map. section 4.6.3
  • Managers and workers use task states to coordinate actions such as scheduling, starting, and stopping tasks. section 2.7

Minimal Go representation

A Go enum-like type makes Pending an explicit value in the task state machine: `type State int`, followed by `Pending State = iota`, `Scheduled`, `Running`, `Completed`, and `Failed`. section 2.1

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 check which event-driven moves are valid from Pending and which states remain unreachable directly from it. section 4.6.3

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

How deep it goes
Defines Pending within a five-state lifecycle and specifies its valid transition to Scheduled, without detailing scheduling internals.
Examples
Uses an enqueued user task, a Go State enumeration, and a transition table mapping Pending to Scheduled.
What you can do after
Diagnose/debug with it, validate whether a task may move from Pending to Scheduled.
How it connects
Connects task lifecycle, scheduling, workers, managers, and state transitions.

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.