Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
chore: add config whenever want to dispatch message
Browse files Browse the repository at this point in the history
  • Loading branch information
KagChi committed Mar 3, 2024
1 parent 70bfa45 commit 85980f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions services/kanao-cache/src/Listeners/Caches/DispatchListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { GatewayDispatchPayload } from "discord-api-types/v10";
import { GatewayDispatchEvents } from "discord-api-types/v10";
import type { ListenerContext } from "../../Stores/Listener.js";
import { Listener } from "../../Stores/Listener.js";
import { clientId } from "../../config.js";
import { clientId, dispatchMessage } from "../../config.js";

export class DispatchListener extends Listener {
public constructor(context: ListenerContext) {
Expand Down Expand Up @@ -45,9 +45,10 @@ export class DispatchListener extends Listener {
}

public static async dispatch(payload: { shardId: number; data: GatewayDispatchPayload; }): Promise<void> {
const routing = new RoutedQueue(GatewayExchangeRoutes.DISPATCH, clientId)
.shard(payload.shardId);

await container.client.cacheQueue.publish(RabbitMQ.GATEWAY_EXCHANGE, routing.key, Buffer.from(JSON.stringify(payload.data)));
if (dispatchMessage) {
const routing = new RoutedQueue(GatewayExchangeRoutes.DISPATCH, clientId)
.shard(payload.shardId);
await container.client.cacheQueue.publish(RabbitMQ.GATEWAY_EXCHANGE, routing.key, Buffer.from(JSON.stringify(payload.data)));
}
}
}
1 change: 1 addition & 0 deletions services/kanao-cache/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ 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 ?? 500);
export const dispatchMessage = process.env.DISPATCH_MESSAGE ? process.env.DISPATCH_MESSAGE === "true" : true;

0 comments on commit 85980f5

Please sign in to comment.