feat: 시계 reconciliation 워커와 명령 경계 완성
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
type TurnDaemonCommand,
|
||||
type TurnDaemonCommandResult,
|
||||
} from '@sammo-ts/common';
|
||||
import type { GamePrisma, GamePrismaClient } from '@sammo-ts/infra';
|
||||
import { readInputEventClockCoordinate, type GamePrisma, type GamePrismaClient } from '@sammo-ts/infra';
|
||||
|
||||
import type { GatewayAdminActionRecord, GatewayAdminActionResult } from './gatewayAdminActions.js';
|
||||
|
||||
@@ -97,13 +97,20 @@ const ensureEngineCommand = async (
|
||||
settings,
|
||||
};
|
||||
try {
|
||||
await db.inputEvent.create({
|
||||
data: {
|
||||
requestId,
|
||||
target: 'ENGINE',
|
||||
eventType: command.type,
|
||||
payload: asJson(command),
|
||||
},
|
||||
await db.$transaction(async (transaction) => {
|
||||
const coordinate = await readInputEventClockCoordinate(transaction);
|
||||
await transaction.inputEvent.create({
|
||||
data: {
|
||||
requestId,
|
||||
target: 'ENGINE',
|
||||
eventType: command.type,
|
||||
payload: asJson(command),
|
||||
acceptedGameTick: coordinate.gameTick,
|
||||
acceptedClockRevision: coordinate.clockRevision,
|
||||
acceptedDeadlineGeneration: coordinate.deadlineGeneration,
|
||||
createdAt: coordinate.wallAt,
|
||||
},
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
if (!isUniqueConflict(error)) throw error;
|
||||
|
||||
Reference in New Issue
Block a user