You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
chore: mark private variables as such and remove obsolete ones
This commit is contained in:
@@ -16,7 +16,7 @@ var reconnect = function (client, why, err) {
|
||||
}
|
||||
|
||||
function onStreamError (client, err) {
|
||||
if (client.closing) {
|
||||
if (client._closing) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ function onStreamError (client, err) {
|
||||
client.ready = false
|
||||
|
||||
// Only emit the error if the retryStrategy option is not set
|
||||
if (client.retryStrategyProvided === false) {
|
||||
if (client._retryStrategyProvided === false) {
|
||||
client.emit('error', err)
|
||||
}
|
||||
// 'error' events get turned into exceptions if they aren't listened for. If the user handled this error
|
||||
@@ -61,7 +61,7 @@ function createParser (client) {
|
||||
setImmediate(() => client.emit('error', err))
|
||||
},
|
||||
returnBuffers: client.buffers || client.messageBuffers,
|
||||
stringNumbers: client.options.stringNumbers || false
|
||||
stringNumbers: client._options.stringNumbers || false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -78,12 +78,12 @@ function connect (client) {
|
||||
const parser = createParser(client)
|
||||
client._replyParser = parser
|
||||
|
||||
if (client.options.stream) {
|
||||
if (client._options.stream) {
|
||||
// Only add the listeners once in case of a reconnect try (that won't work)
|
||||
if (client._stream) {
|
||||
return
|
||||
}
|
||||
client._stream = client.options.stream
|
||||
client._stream = client._options.stream
|
||||
} else {
|
||||
// On a reconnect destroy the former stream and retry
|
||||
if (client._stream) {
|
||||
@@ -92,25 +92,25 @@ function connect (client) {
|
||||
}
|
||||
|
||||
/* istanbul ignore if: travis does not work with stunnel atm. Therefore the tls tests are skipped on travis */
|
||||
if (client.options.tls) {
|
||||
client._stream = tls.connect(client.connectionOptions)
|
||||
if (client._options.tls) {
|
||||
client._stream = tls.connect(client._connectionOptions)
|
||||
} else {
|
||||
client._stream = net.createConnection(client.connectionOptions)
|
||||
client._stream = net.createConnection(client._connectionOptions)
|
||||
}
|
||||
}
|
||||
|
||||
const stream = client._stream
|
||||
|
||||
if (client.options.connectTimeout) {
|
||||
if (client._options.connectTimeout) {
|
||||
// TODO: Investigate why this is not properly triggered
|
||||
stream.setTimeout(client.connectTimeout, () => {
|
||||
stream.setTimeout(client._options.connectTimeout, () => {
|
||||
// Note: This is only tested if a internet connection is established
|
||||
reconnect(client, 'timeout')
|
||||
})
|
||||
}
|
||||
|
||||
/* istanbul ignore next: travis does not work with stunnel atm. Therefore the tls tests are skipped on travis */
|
||||
const connectEvent = client.options.tls ? 'secureConnect' : 'connect'
|
||||
const connectEvent = client._options.tls ? 'secureConnect' : 'connect'
|
||||
stream.once(connectEvent, () => {
|
||||
stream.removeAllListeners('timeout')
|
||||
client.timesConnected++
|
||||
@@ -142,11 +142,13 @@ function connect (client) {
|
||||
|
||||
stream.setNoDelay()
|
||||
|
||||
// Fire the command before redis is connected to be sure it's the first fired command
|
||||
if (client.authPass !== undefined) {
|
||||
// Fire the command before redis is connected to be sure it's the first fired command.
|
||||
// TODO: Consider calling the ready check before Redis is connected as well.
|
||||
// That could improve the ready performance. Measure the rough time difference!
|
||||
if (client._options.password !== undefined) {
|
||||
client.ready = true
|
||||
client.auth(client.authPass).catch((err) => {
|
||||
client.closing = true
|
||||
client.auth(client._options.password).catch((err) => {
|
||||
client._closing = true
|
||||
process.nextTick(() => {
|
||||
client.emit('error', err)
|
||||
client.end(true)
|
||||
|
Reference in New Issue
Block a user