Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup imports and use exported type and enum from socket.io-adapter #16

Merged
merged 4 commits into from
Feb 27, 2024
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
40 changes: 13 additions & 27 deletions lib/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {
ClusterAdapterWithHeartbeat,
type ClusterMessage,
type PrivateSessionId,
type Session,
type ServerId,
type ClusterResponse,
import { ClusterAdapterWithHeartbeat, MessageType } from "socket.io-adapter";
import type {
ClusterAdapterOptions,
ClusterMessage,
PrivateSessionId,
Session,
ServerId,
ClusterResponse,
} from "socket.io-adapter";
import { decode, encode } from "@msgpack/msgpack";
import debugModule from "debug";
Expand All @@ -14,20 +15,6 @@ const debug = debugModule("socket.io-redis-streams-adapter");

const RESTORE_SESSION_MAX_XRANGE_CALLS = 100;

// TODO ClusterAdapterOptions should be exported by the socket.io-adapter package
interface ClusterAdapterOptions {
/**
* The number of ms between two heartbeats.
* @default 5_000
*/
heartbeatInterval?: number;
/**
* The number of ms without heartbeat before we consider a node down.
* @default 10_000
*/
heartbeatTimeout?: number;
}

export interface RedisStreamsAdapterOptions {
/**
* The name of the Redis stream.
Expand Down Expand Up @@ -188,13 +175,12 @@ class RedisStreamsAdapter extends ClusterAdapterWithHeartbeat {

// @ts-ignore
if (message.data) {
// TODO MessageType should be exported by the socket.io-adapter package
const mayContainBinary = [
3, // MessageType.BROADCAST,
8, // MessageType.FETCH_SOCKETS_RESPONSE,
9, // MessageType.SERVER_SIDE_EMIT,
10, // MessageType.SERVER_SIDE_EMIT_RESPONSE,
12, // MessageType.BROADCAST_ACK,
MessageType.BROADCAST,
MessageType.FETCH_SOCKETS_RESPONSE,
MessageType.SERVER_SIDE_EMIT,
MessageType.SERVER_SIDE_EMIT_RESPONSE,
MessageType.BROADCAST_ACK,
].includes(message.type);

// @ts-ignore
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"debug": "~4.3.1"
},
"peerDependencies": {
"socket.io-adapter": "^2.5.3"
"socket.io-adapter": "^2.5.4"
},
"devDependencies": {
"@types/expect.js": "^0.3.29",
Expand Down