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

@@ -9,7 +9,7 @@ import {
RiotAccountEnrichmentService,
} from '../riot/riot-account-enrichment.service';
import { RiotRateLimiterService } from '../riot/riot-rate-limiter.service';
import { GarnetService } from '../global/garnet/garnet.service';
import { RedisService } from '../global/redis/redis.service';
import { isInKstBackgroundWindow } from './kst-window.util';
import { StaleAccountRepository } from './stale-account.repository';
@@ -41,7 +41,7 @@ export class BackgroundRefreshScheduler
private readonly consumer = `${process.pid}:${Math.random().toString(36).slice(2)}`;
constructor(
private readonly garnet: GarnetService,
private readonly redis: RedisService,
private readonly rateLimiter: RiotRateLimiterService,
private readonly enrichmentService: RiotAccountEnrichmentService,
private readonly staleAccountRepository: StaleAccountRepository,
@@ -158,9 +158,9 @@ export class BackgroundRefreshScheduler
}
private async tryBecomeLeader(): Promise<boolean> {
const current = await this.garnet.getString(LEADER_KEY);
const current = await this.redis.getString(LEADER_KEY);
if (current === this.consumer) {
await this.garnet.setString(
await this.redis.setString(
LEADER_KEY,
this.consumer,
LEADER_TTL_SECONDS,
@@ -169,7 +169,7 @@ export class BackgroundRefreshScheduler
}
if (current) return false;
return this.garnet.setStringIfAbsent(
return this.redis.setStringIfAbsent(
LEADER_KEY,
this.consumer,
LEADER_TTL_SECONDS,
@@ -178,9 +178,9 @@ export class BackgroundRefreshScheduler
private async renewLeaderIfHeld(): Promise<void> {
try {
const current = await this.garnet.getString(LEADER_KEY);
const current = await this.redis.getString(LEADER_KEY);
if (current !== this.consumer) return;
await this.garnet.setString(
await this.redis.setString(
LEADER_KEY,
this.consumer,
LEADER_TTL_SECONDS,
@@ -200,7 +200,7 @@ export class BackgroundRefreshScheduler
}
private async getFailureCount(puuid: string): Promise<number> {
const raw = await this.garnet.getString(this.failureBackoffKey(puuid));
const raw = await this.redis.getString(this.failureBackoffKey(puuid));
const count = Number(raw ?? 0);
if (!Number.isFinite(count) || count < 0) return 0;
return count;
@@ -208,7 +208,7 @@ export class BackgroundRefreshScheduler
private async bumpFailureCounter(puuid: string): Promise<void> {
const key = this.failureBackoffKey(puuid);
const client = this.garnet.raw();
const client = this.redis.raw();
const response = await client.sendCommand(['INCR', key]);
await client.sendCommand([
'EXPIRE',
@@ -225,7 +225,7 @@ export class BackgroundRefreshScheduler
}
private async clearFailureCounter(puuid: string): Promise<void> {
await this.garnet.delete(this.failureBackoffKey(puuid));
await this.redis.delete(this.failureBackoffKey(puuid));
}
private isFailedEnrichment(result: EnrichResult): boolean {