feat: redesign auction engine with redis sot

This commit is contained in:
dahyeon committed 2026-06-23 03:16:04 -07:00
1 parent 737702d78c
commit e8bb20d988
75 files changed
+12737 -542

No files matched your search

@@ -16,7 +16,7 @@ import type {
RiotMatch as StoredRiotMatch,
UserDocument,
} from '../global/database/schema';
import { GarnetService } from '../global/garnet/garnet.service';
import { RedisService } from '../global/redis/redis.service';
import { RIOT_JOB_LOW_STREAM } from '../riot-job-queue/riot-job-queue.types';
import { RiotMatchService } from '../riot/riot-match.service';
import type { RiotMatchDto, RiotRegionalRoute } from '../riot/riot.types';
@@ -53,7 +53,7 @@ export class LegacyImportService {
constructor(
private readonly connectionService: ConnectionService,
private readonly garnetService: GarnetService,
private readonly redisService: RedisService,
private readonly riotMatchService: RiotMatchService,
private readonly communityStatsService: CommunityStatsService,
private readonly matchStatsService: MatchStatsService,
@@ -80,7 +80,7 @@ export class LegacyImportService {
}): Promise<StartLegacyImportResponse> {
const lockKey = this.communityLockKey(params.communityId);
const jobId = randomUUID();
const acquired = await this.garnetService.setStringIfAbsent(
const acquired = await this.redisService.setStringIfAbsent(
lockKey,
jobId,
LEGACY_IMPORT_LOCK_TTL_SECONDS,
@@ -148,7 +148,7 @@ export class LegacyImportService {
triggeredBy: params.triggeredBy.toString(),
region: (community.riotRegion ?? 'asia') as RiotRegionalRoute,
};
await this.garnetService.appendStream(
await this.redisService.appendStream(
RIOT_JOB_LOW_STREAM,
{ job: JSON.stringify(job) },
{ maxLen: 10_000 },
@@ -160,7 +160,7 @@ export class LegacyImportService {
{ jobId },
{ $set: { state: 'completed', completedAt: new Date() } },
).exec();
await this.garnetService.delete(lockKey);
await this.redisService.delete(lockKey);
}
return {
@@ -169,7 +169,7 @@ export class LegacyImportService {
etaSeconds: windows.length * LEGACY_IMPORT_MEMBER_AVG_SECONDS,
};
} catch (error) {
await this.garnetService.delete(lockKey);
await this.redisService.delete(lockKey);
throw error;
}
}
@@ -220,7 +220,7 @@ export class LegacyImportService {
).exec();
if (!job)
throw new NotFoundException('Running legacy import job not found.');
await this.garnetService.delete(this.communityLockKey(params.communityId));
await this.redisService.delete(this.communityLockKey(params.communityId));
return job;
}
@@ -500,7 +500,7 @@ export class LegacyImportService {
userByPuuid: UserByPuuidMap,
): Promise<ImportOutcome> {
const lockKey = `legacy-import:match:${riotMatchId}`;
const acquired = await this.garnetService.setStringIfAbsent(
const acquired = await this.redisService.setStringIfAbsent(
lockKey,
job.parentJobId,
MATCH_IMPORT_LOCK_TTL_SECONDS,
@@ -577,7 +577,7 @@ export class LegacyImportService {
});
return 'error';
} finally {
await this.garnetService.delete(lockKey);
await this.redisService.delete(lockKey);
}
}
@@ -656,7 +656,7 @@ export class LegacyImportService {
if (completed) {
await Promise.all([
this.garnetService.delete(
this.redisService.delete(
this.communityLockKey(new mongoose.Types.ObjectId(job.communityId)),
),
this.communityStatsService.invalidateCommunity(