feat: redesign auction engine with redis sot
This commit is contained in:
1 parent
737702d78c
commit
e8bb20d988
75 files changed
+12737
-542
No files matched your search
@@ -6,7 +6,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import mongoose from 'mongoose';
|
||||
import { ConnectionService } from '../global/database/connection.service';
|
||||
import { GarnetService, StreamEntry } from '../global/garnet/garnet.service';
|
||||
import { RedisService, StreamEntry } from '../global/redis/redis.service';
|
||||
import { LegacyImportService } from '../legacy-import/legacy-import.service';
|
||||
import type { LegacyImportMemberJob } from '../legacy-import/legacy-import.types';
|
||||
import { RiotAccountEnrichmentService } from '../riot/riot-account-enrichment.service';
|
||||
@@ -33,7 +33,7 @@ export class RiotJobWorkerService implements OnModuleInit, OnModuleDestroy {
|
||||
private stopped = false;
|
||||
|
||||
constructor(
|
||||
private readonly garnetService: GarnetService,
|
||||
private readonly redisService: RedisService,
|
||||
private readonly jobQueueService: RiotJobQueueService,
|
||||
private readonly recentMatchesService: RiotRecentMatchesService,
|
||||
private readonly connectionService: ConnectionService,
|
||||
@@ -145,7 +145,7 @@ export class RiotJobWorkerService implements OnModuleInit, OnModuleDestroy {
|
||||
stream: string,
|
||||
id: string,
|
||||
): Promise<void> {
|
||||
await this.garnetService.acknowledgeStream(stream, RIOT_JOB_GROUP, id);
|
||||
await this.redisService.acknowledgeStream(stream, RIOT_JOB_GROUP, id);
|
||||
await this.deleteAcknowledgedEntry(stream, id);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ export class RiotJobWorkerService implements OnModuleInit, OnModuleDestroy {
|
||||
id: string,
|
||||
): Promise<void> {
|
||||
try {
|
||||
await this.garnetService.deleteStreamEntries(stream, id);
|
||||
await this.redisService.deleteStreamEntries(stream, id);
|
||||
} catch (error) {
|
||||
this.logger.warn(
|
||||
`Failed to delete acknowledged Riot job stream entry ${stream} ${id}: ${
|
||||
@@ -226,7 +226,7 @@ export class RiotJobWorkerService implements OnModuleInit, OnModuleDestroy {
|
||||
stream: string,
|
||||
blockMs: number,
|
||||
): Promise<{ stream: string; message: StreamEntry } | null> {
|
||||
const result = await this.garnetService.readGroup(
|
||||
const result = await this.redisService.readGroup(
|
||||
stream,
|
||||
RIOT_JOB_GROUP,
|
||||
this.consumer,
|
||||
@@ -241,7 +241,7 @@ export class RiotJobWorkerService implements OnModuleInit, OnModuleDestroy {
|
||||
await Promise.all(
|
||||
[RIOT_JOB_HIGH_STREAM, RIOT_JOB_LOW_STREAM].map(async (stream) => {
|
||||
try {
|
||||
await this.garnetService.createConsumerGroup(stream, RIOT_JOB_GROUP);
|
||||
await this.redisService.createConsumerGroup(stream, RIOT_JOB_GROUP);
|
||||
} catch (error) {
|
||||
const message =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
@@ -252,9 +252,9 @@ export class RiotJobWorkerService implements OnModuleInit, OnModuleDestroy {
|
||||
}
|
||||
|
||||
private async tryBecomeLeader(): Promise<boolean> {
|
||||
const current = await this.garnetService.getString(LEADER_KEY);
|
||||
const current = await this.redisService.getString(LEADER_KEY);
|
||||
if (current === this.consumer) {
|
||||
await this.garnetService.setString(
|
||||
await this.redisService.setString(
|
||||
LEADER_KEY,
|
||||
this.consumer,
|
||||
LEADER_TTL_SECONDS,
|
||||
@@ -262,7 +262,7 @@ export class RiotJobWorkerService implements OnModuleInit, OnModuleDestroy {
|
||||
return true;
|
||||
}
|
||||
if (current) return false;
|
||||
return this.garnetService.setStringIfAbsent(
|
||||
return this.redisService.setStringIfAbsent(
|
||||
LEADER_KEY,
|
||||
this.consumer,
|
||||
LEADER_TTL_SECONDS,
|
||||
|
||||
Reference in new issue
Block a user