Repository navigation
Commit 6673de7
committed
feat[models]: Add terminal-state predicates for all four entities
An embedding application had no supported way to ask whether a Task,
TaskExecution, Workflow, or WorkflowStep is done and can no longer move; it
had to hardcode a state list. Internally the same question was answered by
several private predicates, each independently restating sets owned by the
state machines in `models`.
Adds `IsTerminal()` on the four state ENUMs and `HasReachedTerminalState()` on
the four structs. Both derive from the transition graph - a state is terminal
iff it has no outgoing transition - so they cannot drift from the state machine
they describe. To make that possible the transition maps that were rebuilt as
locals inside Task/Workflow/WorkflowStep ValidNextState are hoisted to package
level, matching taskExecutionStateTransitions. ValidNextState is unchanged.
Candidates come from each ENUM's Values(), so an unrecognized state reads as
non-terminal rather than silently terminal.
Five internal duplicates now defer to it, none changing behavior:
db.isTerminalTaskState and db.isTerminalWorkflowState are deleted,
workflow.nonTerminalWorkflowStates and db/workflow.go's inline step list use
the new NonTerminalWorkflow{,Step}States accessors, and the cancellable-state
switch in processCancelTask becomes !HasReachedTerminalState().
Left alone on purpose: workflow's isTerminalWorkflowStepState is the weaker
settle/dispatch reading (it counts FAILED / TIMED_OUT, which a revive moves),
as are the scheduler's hard-stop policy sets and TaskExecution.HasEnded. Each
now carries a doc note on which reading applies when.1 parent 8c60640 commit 6673de7
11 files changed
Lines changed: 646 additions & 124 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | 356 | | |
366 | 357 | | |
367 | 358 | | |
| |||
377 | 368 | | |
378 | 369 | | |
379 | 370 | | |
380 | | - | |
| 371 | + | |
381 | 372 | | |
382 | 373 | | |
383 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | 409 | | |
416 | 410 | | |
417 | 411 | | |
| |||
441 | 435 | | |
442 | 436 | | |
443 | 437 | | |
444 | | - | |
| 438 | + | |
445 | 439 | | |
446 | 440 | | |
447 | 441 | | |
| |||
549 | 543 | | |
550 | 544 | | |
551 | 545 | | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
| 546 | + | |
556 | 547 | | |
557 | 548 | | |
558 | 549 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments