diff --git a/services/kanao-cache/src/Structures/KanaoCache.ts b/services/kanao-cache/src/Structures/KanaoCache.ts index b0586305..7cc59ea1 100644 --- a/services/kanao-cache/src/Structures/KanaoCache.ts +++ b/services/kanao-cache/src/Structures/KanaoCache.ts @@ -10,7 +10,7 @@ import { drizzle } from "drizzle-orm/node-postgres"; import pg from "pg"; import { ListenerStore } from "../Stores/ListenerStore.js"; import { createLogger } from "../Utilities/Logger.js"; -import { clientId, storeLogs, lokiHost, databaseUrl, amqp, databaseConnectionLimit } from "../config.js"; +import { clientId, storeLogs, lokiHost, databaseUrl, amqp, databaseConnectionLimit, prefetchCount } from "../config.js"; export class KanaoCache extends EventEmitter { public cacheQueue = createAmqpChannel(amqp, { @@ -45,7 +45,7 @@ export class KanaoCache extends EventEmitter { const routingKey = new RoutedQueue(GatewayExchangeRoutes.RECEIVE, clientId, "cache"); const { queue } = await channel.assertQueue(routingKey.queue, { durable: false }); - await channel.prefetch(1); + await channel.prefetch(prefetchCount); await channel.bindQueue(queue, "kanao-gateway", routingKey.key); await channel.consume(queue, message => { if (message) { diff --git a/services/kanao-cache/src/config.ts b/services/kanao-cache/src/config.ts index 12bd42eb..1b36fcd9 100644 --- a/services/kanao-cache/src/config.ts +++ b/services/kanao-cache/src/config.ts @@ -20,3 +20,5 @@ export const stateChannels = process.env.STATE_CHANNEL === "true"; export const stateMessages = process.env.STATE_MESSAGE === "true"; export const guildCreateGcEvery = Number(process.env.GUILD_CREATE_GC_EVERY ?? 150); + +export const prefetchCount = Number(process.env.PREFETCH_COUNT ?? 50);