MCPcopy
hub / github.com/redis/node-redis / RedisSocket

Class RedisSocket

packages/client/lib/client/socket.ts:59–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57export type RedisSocketInitiator = () => void | Promise<unknown>;
58
59export default class RedisSocket extends EventEmitter {
60 readonly #initiator;
61 readonly #connectTimeout;
62 readonly #reconnectStrategy;
63 readonly #socketFactory;
64 readonly #socketTimeout;
65 readonly #clientId: string;
66
67 #maintenanceTimeout: number | undefined;
68
69 #socket?: net.Socket | tls.TLSSocket;
70
71 #isOpen = false;
72
73 get isOpen() {
74 return this.#isOpen;
75 }
76
77 #isReady = false;
78
79 get isReady() {
80 return this.#isReady;
81 }
82
83 #isSocketUnrefed = false;
84
85 #socketEpoch = 0;
86
87 get socketEpoch() {
88 return this.#socketEpoch;
89 }
90
91 get host() {
92 return this.#socket?.remoteAddress;
93 }
94
95 get port() {
96 return this.#socket?.remotePort;
97 }
98
99 constructor(
100 initiator: RedisSocketInitiator,
101 clientId: string,
102 options?: RedisSocketOptions,
103 ) {
104 super();
105
106 this.#initiator = initiator;
107 this.#connectTimeout = options?.connectTimeout ?? 5000;
108 this.#reconnectStrategy = this.#createReconnectStrategy(options);
109 this.#socketFactory = this.#createSocketFactory(options);
110 this.#socketTimeout = options?.socketTimeout;
111 this.#clientId = clientId;
112 }
113
114 #createReconnectStrategy(options?: RedisSocketOptions): ReconnectStrategyFunction {
115 const strategy = options?.reconnectStrategy;
116 if (strategy === false || typeof strategy === 'number') {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected