@@ -6,9 +6,33 @@ type BatchState string
66const (
77 // BatchStateUnknown is the unreachable state. It is set by default when the structure is initialized. It should never be seen in the system.
88 BatchStateUnknown BatchState = ""
9- // TODO: Add comprehensive list of known batch states.
9+ // BatchStateScheduled is the state of a batch that has been scheduled for processing.
10+ BatchStateScheduled BatchState = "scheduled"
11+ // BatchStateSpeculating is the state of a batch that is undergoing speculative execution.
12+ BatchStateSpeculating BatchState = "speculating"
13+ // BatchStateFinalizing is the state of a batch that is being finalized after speculative execution.
14+ BatchStateFinalizing BatchState = "finalizing"
15+ // BatchStateSucceeded is the terminal state of a batch that has been successfully landed.
16+ BatchStateSucceeded BatchState = "succeeded"
17+ // BatchStateFailed is the terminal state of a batch that has failed to land.
18+ BatchStateFailed BatchState = "failed"
19+ // BatchStateCancelled is the terminal state of a batch that was cancelled before completion.
20+ BatchStateCancelled BatchState = "cancelled"
21+ // BatchStateCancellationFailed is the terminal state of a batch whose cancellation process itself failed.
22+ BatchStateCancellationFailed BatchState = "cancellationfailed"
1023)
1124
25+ // IsTerminal returns true if the batch state is a terminal state.
26+ // Terminal states are states from which no further transitions are possible.
27+ func (s BatchState ) IsTerminal () bool {
28+ switch s {
29+ case BatchStateSucceeded , BatchStateFailed , BatchStateCancelled , BatchStateCancellationFailed :
30+ return true
31+ default :
32+ return false
33+ }
34+ }
35+
1236// Batch represents a group of requests to land (merge into target branch of the source control repository).
1337type Batch struct {
1438 // ID is the globally unique identifier for the batch. Format: "<queue>/batch/<counter_value>".
0 commit comments