You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
chore: refactor main code base into smaller parts
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
const tls = require('tls')
|
||||
const Parser = require('redis-parser')
|
||||
const net = require('net')
|
||||
const reconnect = require('./reconnect')
|
||||
const onConnect = require('./readyHandler')
|
||||
const debug = require('./debug')
|
||||
|
||||
/**
|
||||
@@ -77,7 +79,7 @@ function connect (client) {
|
||||
// TODO: Investigate why this is not properly triggered
|
||||
client._stream.setTimeout(client.connectTimeout, () => {
|
||||
// Note: This is only tested if a internet connection is established
|
||||
client.connectionGone('timeout')
|
||||
reconnect(client, 'timeout')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -86,7 +88,7 @@ function connect (client) {
|
||||
client._stream.once(connectEvent, () => {
|
||||
client._stream.removeAllListeners('timeout')
|
||||
client.timesConnected++
|
||||
client.onConnect()
|
||||
onConnect(client)
|
||||
})
|
||||
|
||||
client._stream.on('data', (bufferFromSocket) => {
|
||||
@@ -105,11 +107,11 @@ function connect (client) {
|
||||
})
|
||||
|
||||
client._stream.once('close', (hadError) => {
|
||||
client.connectionGone('close')
|
||||
reconnect(client, 'close')
|
||||
})
|
||||
|
||||
client._stream.once('end', () => {
|
||||
client.connectionGone('end')
|
||||
reconnect(client, 'end')
|
||||
})
|
||||
|
||||
client._stream.setNoDelay()
|
||||
|
Reference in New Issue
Block a user