(options?: RedisSocketOptions)
| 112 | } |
| 113 | |
| 114 | #createReconnectStrategy(options?: RedisSocketOptions): ReconnectStrategyFunction { |
| 115 | const strategy = options?.reconnectStrategy; |
| 116 | if (strategy === false || typeof strategy === 'number') { |
| 117 | return () => strategy; |
| 118 | } |
| 119 | |
| 120 | if (strategy) { |
| 121 | return (retries, cause) => { |
| 122 | try { |
| 123 | const retryIn = strategy(retries, cause); |
| 124 | if (retryIn !== false && !(retryIn instanceof Error) && typeof retryIn !== 'number') { |
| 125 | throw new TypeError(`Reconnect strategy should return \`false | Error | number\`, got ${retryIn} instead`); |
| 126 | } |
| 127 | return retryIn; |
| 128 | } catch (err) { |
| 129 | publish(CHANNELS.ERROR, () => ({ |
| 130 | error: err as Error, |
| 131 | origin: 'client', |
| 132 | internal: false, |
| 133 | clientId: this.#clientId |
| 134 | })); |
| 135 | this.emit('error', err); |
| 136 | return this.defaultReconnectStrategy(retries, err); |
| 137 | } |
| 138 | }; |
| 139 | } |
| 140 | |
| 141 | return this.defaultReconnectStrategy; |
| 142 | } |
| 143 | |
| 144 | #createSocketFactory(options?: RedisSocketOptions) { |
| 145 | // TLS |
no test coverage detected