perf: 공유 지도와 토너먼트 revision을 원자화

지도 캐시는 coverage가 확인된 PostgreSQL map.world head만 사용하고 실패 시 전체 계산으로 복구한다. 토너먼트 Redis payload와 source revision은 Lua 한 번으로 갱신한다.
This commit is contained in:
2026-08-16 18:37:48 +00:00
parent 7e099326ec
commit e4ac2a60b1
13 changed files with 482 additions and 55 deletions
@@ -0,0 +1,41 @@
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { createGamePostgresConnector, type GamePrismaClient } from '@sammo-ts/infra';
import { readMapWorldSourceRevision } from '../src/maps/worldMapSourceRevision.js';
const databaseUrl = process.env.INPUT_EVENT_DATABASE_URL;
const integration = describe.skipIf(!databaseUrl);
integration('world map PostgreSQL source revision', () => {
let db: GamePrismaClient;
let close: (() => Promise<void>) | undefined;
beforeAll(async () => {
const connector = createGamePostgresConnector({ url: databaseUrl! });
await connector.connect();
db = connector.prisma;
close = () => connector.disconnect();
});
afterAll(async () => close?.());
it('reads coverage and map.world from the same transaction snapshot', async () => {
const rollback = new Error('rollback map revision fixture');
await expect(
db.$transaction(async (transaction) => {
await transaction.readModelRevisionMeta.upsert({
where: { id: 1 },
create: { id: 1, coverageVersion: 1 },
update: { coverageVersion: 1 },
});
await transaction.readModelRevision.upsert({
where: { domain_entityId: { domain: 'map.world', entityId: 0 } },
create: { domain: 'map.world', entityId: 0, revision: 37n },
update: { revision: 37n },
});
await expect(readMapWorldSourceRevision(transaction)).resolves.toBe('37');
throw rollback;
})
).rejects.toBe(rollback);
});
});