Skip to content

Commit b8c20e8

Browse files
committed
Remove unnecessary control logic and otherwise simplify main loop
1 parent fa17b47 commit b8c20e8

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

Diff for: updates_and_signals/safe_message_handlers/src/workflows.ts

+7-14
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,12 @@ export async function clusterManagerWorkflow(input: ClusterManagerInput): Promis
4444
//
4545
// The cluster manager workflow is a long-running workflow ("entity" workflow). Most of its logic
4646
// lies in the message-processing handlers implented in the ClusterManager class. The main
47-
// workflow itself is a loop that does the following:
48-
// - process messages
49-
// - continue-as-new when suggested
50-
//
51-
await wf.condition(() => manager.state.clusterStarted);
52-
for (;;) {
53-
await wf.condition(() => manager.state.clusterShutdown || wf.workflowInfo().continueAsNewSuggested);
54-
if (manager.state.clusterShutdown) {
55-
break;
56-
}
57-
if (wf.workflowInfo().continueAsNewSuggested) {
58-
await wf.continueAsNew<typeof clusterManagerWorkflow>({ state: manager.getState() });
59-
}
47+
// workflow itself simply waits until the cluster is shutdown, or the workflow needs to
48+
// continue-as-new.
49+
await wf.condition(() => manager.state.clusterShutdown || wf.workflowInfo().continueAsNewSuggested);
50+
if (wf.workflowInfo().continueAsNewSuggested) {
51+
await wf.continueAsNew<typeof clusterManagerWorkflow>({ state: manager.getState() });
52+
} else {
53+
return manager.getStateSummary();
6054
}
61-
return manager.getStateSummary();
6255
}

0 commit comments

Comments
 (0)