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

Commit

Permalink
fix(rpc): use different routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazmi35 authored Feb 23, 2024
1 parent d270c39 commit 4c07547
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions services/kanao-gateway/src/Structures/KanaoGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,13 @@ export class NezuGateway extends EventEmitter {
await channel.assertExchange(RabbitMQ.GATEWAY_EXCHANGE, "topic", { durable: false });

// Used for Stats RPC
const routing = new RoutedQueue(GatewayExchangeRoutes.REQUEST, clientId, `gateway-rpc-${replicaId}`);
await channel.assertQueue(routing.queue, { durable: false });
await channel.bindQueue(routing.queue, RabbitMQ.GATEWAY_EXCHANGE, routing.key);
const rpc = new RoutedQueue(`${GatewayExchangeRoutes.REQUEST}.stats`, clientId, `gateway-rpc-${replicaId}`);
await channel.assertQueue(rpc.queue, { durable: false });
await channel.bindQueue(rpc.queue, RabbitMQ.GATEWAY_EXCHANGE, rpc.key);

await channel.consume(routing.queue, async message => {
await channel.consume(rpc.queue, async message => {
if (message) {
const content = JSON.parse(message.content.toString()) as { replyTo: string; request: "counts" | "stats"; };
if (content.request !== "stats") return;

const content = JSON.parse(message.content.toString()) as { replyTo: string; };
const stats = [];
for (const [shardId, status] of await this.ws.fetchStatus()) {
const stat = await this.drizzle.query.status.findFirst({
Expand All @@ -148,7 +146,7 @@ export class NezuGateway extends EventEmitter {
channel.ack(message);
await amqpChannel.sendToQueue(content.replyTo, Buffer.from(
JSON.stringify({
request: content.request,
request: rpc.key,
shards: stats,
replicaId,
clientId,
Expand Down

0 comments on commit 4c07547

Please sign in to comment.