Skip to content

Commit 007bb3f

Browse files
committed
refactor: minor refactor
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
1 parent 266ea74 commit 007bb3f

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

docs/SERVICE_RESTARTS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ restart safe:
5454
A transition's task records, workflow status-set membership, and schedule
5555
snapshot are written as a single atomic Redis transaction
5656
(`WorkflowRegistry.commit_transition`), so a crash mid-persist commits the whole
57-
transition or none of it — never a half-applied state. Event-driven transitions
58-
are additionally healed by replay; the API-driven workflow cancel, which has no
59-
event to replay, relies on this atomicity alone.
57+
transition or none of it. Event-driven transitions are additionally healed by replay;
58+
the API-driven workflow cancel relies on this atomicity alone.
6059
- **Replayable task events.** Task lifecycle events flow through a durable Redis
6160
stream consumed from a persisted cursor. The ordering is what makes replay
6261
safe: a transition is written to durable scheduler state *before* its event is

src/server/task/runtime.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,19 +371,19 @@ def _persisted_task_locked(self, task_id: str) -> PersistedTask | None:
371371
epoch_index=self._task_epoch_index.get(task_id),
372372
)
373373

374-
def _sched_locked(self, workflow_id: str) -> WorkflowSched:
375-
return WorkflowSched(
376-
in_epoch_order=self._workflow_in_epoch_order.get(workflow_id, False),
377-
epoch_frontier=self._workflow_epoch_frontier.get(workflow_id, 0),
378-
)
379-
380374
def _records_locked(self, *task_ids: str) -> list[PersistedTask]:
381375
return [
382376
persisted
383377
for task_id in dict.fromkeys(task_ids)
384378
if (persisted := self._persisted_task_locked(task_id))
385379
]
386380

381+
def _sched_locked(self, workflow_id: str) -> WorkflowSched:
382+
return WorkflowSched(
383+
in_epoch_order=self._workflow_in_epoch_order.get(workflow_id, False),
384+
epoch_frontier=self._workflow_epoch_frontier.get(workflow_id, 0),
385+
)
386+
387387
def _persist_locked(self, *task_ids: str) -> None:
388388
"""Commit task records (no membership change) atomically, per workflow."""
389389
by_workflow: dict[str, list[str]] = defaultdict(list)

0 commit comments

Comments
 (0)