Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions libs/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
"@cordis/common": "workspace:^0.1.7",
"@cordis/error": "workspace:^0.1.7",
"@cordis/queue": "workspace:^0.1.7",
"@cordis/redis-store": "workspace:^0.1.7",
"@cordis/rest": "workspace:^0.1.7",
"@cordis/store": "workspace:^0.1.7",
"common-tags": "^1.8.0",
"discord-api-types": "^0.12.1",
"tslib": "^2.1.0",
Expand Down
9 changes: 0 additions & 9 deletions libs/gateway/src/websocket/Cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import {
} from './WebsocketConnection';
import { stripIndent } from 'common-tags';
import { RestManager, MemoryMutex, RedisMutex } from '@cordis/rest';
import { Store, IStore } from '@cordis/store';
import { RedisStore } from '@cordis/redis-store';
import {
APIGuild,
APIUser,
GatewayDispatchPayload,
GatewaySendPayload,
Expand Down Expand Up @@ -117,11 +114,6 @@ export class Cluster extends EventEmitter {
*/
public readonly shards: WebsocketConnection[] = [];

/**
* Guild storage
*/
public readonly guilds: IStore<APIGuild>;

/**
* REST instance
*/
Expand Down Expand Up @@ -193,7 +185,6 @@ export class Cluster extends EventEmitter {
...shardOptions
} = options;

this.guilds = redis ? new RedisStore({ redis, hash: 'guilds', encode: JSON.stringify, decode: JSON.parse }) : new Store<APIGuild>();
this.rest = new RestManager(auth, { mutex: redis ? new RedisMutex(redis) : new MemoryMutex() });
this.shardCount = shardCount;
this.startingShard = startingShard;
Expand Down
9 changes: 1 addition & 8 deletions libs/gateway/src/websocket/WebsocketConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ export class WebsocketConnection {
}
};

private async _handleDispatch(payload: GatewayDispatchPayload): Promise<void> {
private _handleDispatch(payload: GatewayDispatchPayload) {
if (this._sequence == null || payload.s > this._sequence) this._sequence = payload.s;

switch (payload.t) {
Expand Down Expand Up @@ -758,18 +758,11 @@ export class WebsocketConnection {
}

this._refreshTimeout('guilds');
} else {
await this.cluster.guilds.set(payload.d.id, payload.d);
}

break;
}

case GatewayDispatchEvents.GuildDelete: {
if (!payload.d.unavailable) await this.cluster.guilds.delete(payload.d.id);
break;
}

case GatewayDispatchEvents.Resumed: {
this._clearTimeout('reconnecting');
this.debug(`Resumed Session ${this._sessionId}; Replayed ${payload.s - this._sequence} events`);
Expand Down
22 changes: 12 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions services/gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ COPY libs/common/package.json ./libs/common/
COPY libs/error/package.json ./libs/error/
COPY libs/gateway/package.json ./libs/gateway/
COPY libs/queue/package.json ./libs/queue/
COPY libs/redis-store/package.json ./libs/redis-store/
COPY libs/rest/package.json ./libs/rest/
COPY libs/store/package.json ./libs/store/
COPY services/gateway/package.json ./services/gateway/package.json

RUN pnpm i --frozen-lockfile && apk del .build-deps
Expand All @@ -30,9 +28,7 @@ COPY libs/common ./libs/common
COPY libs/error ./libs/error
COPY libs/gateway ./libs/gateway
COPY libs/queue ./libs/queue
COPY libs/redis-store ./libs/redis-store
COPY libs/rest ./libs/rest
COPY libs/store ./libs/store
COPY services/gateway ./services/gateway

RUN pnpm run build && pnpm prune --prod
Expand Down
3 changes: 0 additions & 3 deletions services/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
"@cordis/brokers": "workspace:^0.1.7",
"@cordis/common": "workspace:^0.1.7",
"@cordis/gateway": "workspace:^0.1.7",
"@cordis/redis-store": "workspace:^0.1.7",
"@cordis/store": "workspace:^0.1.7",
"erlpack": "github:discord/erlpack",
"ioredis": "^4.22.0",
"tslib": "^2.1.0",
"yargs": "^15.4.1",
"zlib-sync": "^0.1.7"
Expand Down
7 changes: 0 additions & 7 deletions services/gateway/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as yargs from 'yargs';
import { createAmqp, RoutingServer, PubSubClient } from '@cordis/brokers';
import createRedis, { Redis } from 'ioredis';
import { Cluster, IntentKeys } from '@cordis/gateway';
import type { DiscordEvents } from '@cordis/common';
import type { GatewaySendPayload } from 'discord-api-types/v8';
Expand Down Expand Up @@ -124,11 +123,6 @@ const main = async () => {
process.exit(1);
});

let redis: Redis | null = null;
if (argv['redis-url']) {
redis = new createRedis(argv['redis-url']);
}

const service = new RoutingServer<keyof DiscordEvents, DiscordEvents>(channel);
const cluster = new Cluster(
argv.auth,
Expand All @@ -142,7 +136,6 @@ const main = async () => {
reconnectTimeout: argv['ws-reconnect-timeout'],
largeThreshold: argv['ws-large-threshold'],
intents: argv['ws-intents'] as IntentKeys[],
redis: redis ?? undefined,
shardCount: argv['shard-count'],
startingShard: argv['starting-shard'],
totalShardCount: argv['total-shard-count']
Expand Down