refactor(game): refresh committed read models selectively

This commit is contained in:
2026-08-09 15:46:01 +00:00
parent 00b9fcdb93
commit a2683df80f
14 changed files with 807 additions and 48 deletions
@@ -351,6 +351,14 @@ export class TurnDaemonLifecycle {
await this.resolveNextRunTime();
}
try {
await this.hooks?.publishCommandEvents?.(result);
} catch (error) {
// The command is already durable. Realtime publication is a
// best-effort read-model invalidation and must not reject it.
this.status.lastError = error instanceof Error ? error.message : 'Unknown command event publication error.';
}
if (this.commandResponder && command.requestId) {
await this.commandResponder.publishCommandResult(command.requestId, result);
}
+1
View File
@@ -70,6 +70,7 @@ export interface TurnDaemonHooks {
requestId: string,
execute: (context: TurnDaemonCommandExecutionContext) => Promise<TurnDaemonCommandResult>
): Promise<TurnDaemonCommandResult>;
publishCommandEvents?(result: TurnDaemonCommandResult): Promise<void>;
publishEvents?(result: TurnRunResult): Promise<void>;
onRunError?(error: unknown): Promise<void>;
}