import { ClusterAdapter } from "socket.io-adapter"; import type { ClusterAdapterOptions, ClusterMessage, PrivateSessionId, Session, ServerId, ClusterResponse } from "socket.io-adapter"; export interface RedisStreamsAdapterOptions { /** * The name of the Redis stream (or the prefix used when using multiple streams). * * @see streamCount * @default "socket.io" */ streamName?: string; /** * The number of streams to use to scale horizontally. * * Each namespace is routed to a specific stream to ensure the ordering of messages. * * Note: using multiple streams is useless when using a single namespace. * * @default 1 */ streamCount?: number; /** * The prefix of the Redis PUB/SUB channels used to communicate between the nodes. * @default "socket.io" */ channelPrefix?: string; /** * Whether to use sharded PUB/SUB (added in Redis 7.0) to communicate between the nodes. * @default false * @see https://redis.io/docs/latest/develop/pubsub/#sharded-pubsub */ useShardedPubSub?: boolean; /** * The maximum size of the stream. Almost exact trimming (~) is used. * @default 10_000 */ maxLen?: number; /** * The number of elements to fetch per XREAD call. * @default 100 */ readCount?: number; /** * The number of ms before the XREAD call times out. * @default 5_000 * @see https://redis.io/docs/latest/commands/xread/#blocking-for-data */ blockTimeInMs?: number; /** * The prefix of the key used to store the Socket.IO session, when the connection state recovery feature is enabled. * @default "sio:session:" */ sessionKeyPrefix?: string; /** * Whether the transmitted data contains only JSON-serializable objects without binary data (Buffer, ArrayBuffer, etc.). * When enabled, binary data checks are skipped for better performance. * @default false */ onlyPlaintext?: boolean; } interface RawClusterMessage { uid: string; nsp: string; type: string; data?: string; } /** * Returns a function that will create a new adapter instance. * * @param redisClient - a Redis client that will be used to publish messages * @param opts - additional options */ export declare function createAdapter(redisClient: any, opts?: RedisStreamsAdapterOptions & ClusterAdapterOptions): (nsp: any) => RedisStreamsAdapter; declare class RedisStreamsAdapter extends ClusterAdapter { #private; constructor(nsp: any, redisClient: any, subClientPromise: Promise, opts: Required & ClusterAdapterOptions); doPublish(message: ClusterMessage): any; protected doPublishResponse(requesterUid: ServerId, response: ClusterResponse): Promise; private encode; onRawMessage(rawMessage: RawClusterMessage, offset: string): any; static decode(rawMessage: RawClusterMessage): ClusterMessage; serverCount(): Promise; persistSession(session: any): void; restoreSession(pid: PrivateSessionId, offset: string): Promise; /** * Exclusive ranges were added in Redis 6.2, so this is necessary for previous versions. * * @see https://redis.io/commands/xrange/ * * @param offset */ static nextOffset(offset: any): string; } export {};