refactor(game): refresh committed read models selectively
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user