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 - remove standard and use individual config
Standard is not as up to date and still uses a old eslint version. Instead, use the airbnb default with a couple of modifications. All required changes are included.
This commit is contained in:
@@ -7,15 +7,13 @@ const debug = require('./debug')
|
||||
const flushAndError = require('./flushAndError')
|
||||
const onConnect = require('./readyHandler')
|
||||
const replyHandler = require('./replyHandler')
|
||||
|
||||
var reconnect
|
||||
|
||||
const onResult = replyHandler.onResult
|
||||
const onError = replyHandler.onError
|
||||
|
||||
var lazyReconnect = function (client, why, err) {
|
||||
lazyReconnect = require('./reconnect')
|
||||
lazyReconnect(client, why, err)
|
||||
}
|
||||
|
||||
function onStreamError (client, err) {
|
||||
function onStreamError(client, err) {
|
||||
if (client._closing) {
|
||||
return
|
||||
}
|
||||
@@ -29,9 +27,10 @@ function onStreamError (client, err) {
|
||||
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
|
||||
// then we should try to reconnect.
|
||||
lazyReconnect(client, 'error', err)
|
||||
// 'error' events get turned into exceptions if they aren't listened for. If
|
||||
// the user handled this error then we should try to reconnect.
|
||||
if (reconnect === undefined) reconnect = require('./reconnect')
|
||||
reconnect(client, 'error', err)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,17 +39,19 @@ function onStreamError (client, err) {
|
||||
* @param {RedisClient} client
|
||||
* @returns JavascriptRedisParser
|
||||
*/
|
||||
function createParser (client) {
|
||||
function createParser(client) {
|
||||
return new Parser({
|
||||
returnReply (data) {
|
||||
returnReply(data) {
|
||||
onResult(client, data)
|
||||
},
|
||||
returnError (err) {
|
||||
returnError(err) {
|
||||
onError(client, err)
|
||||
},
|
||||
returnFatalError (err) {
|
||||
// Error out all fired commands. Otherwise they might rely on faulty data. We have to reconnect to get in a working state again
|
||||
// Note: the execution order is important. First flush and emit, then create the stream
|
||||
returnFatalError(err) {
|
||||
// Error out all fired commands. Otherwise they might rely on faulty data.
|
||||
// We have to reconnect to get in a working state again Note: the
|
||||
// execution order is important. First flush and emit, then create the
|
||||
// stream
|
||||
err.message += '. Please report this.'
|
||||
client.ready = false
|
||||
flushAndError(client, 'Fatal error encountered. Command aborted.', 'NR_FATAL', {
|
||||
@@ -73,7 +74,7 @@ function createParser (client) {
|
||||
*
|
||||
* @param {RedisClient} client
|
||||
*/
|
||||
function connect (client) {
|
||||
function connect(client) {
|
||||
// Init parser
|
||||
const parser = createParser(client)
|
||||
const options = client._options
|
||||
@@ -106,7 +107,8 @@ function connect (client) {
|
||||
// TODO: Check if this works with tls.
|
||||
stream.setTimeout(client._connectTimeout, () => {
|
||||
// Note: This is only tested if a internet connection is established
|
||||
lazyReconnect(client, 'timeout')
|
||||
if (reconnect === undefined) reconnect = require('./reconnect')
|
||||
reconnect(client, 'timeout')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -127,11 +129,13 @@ function connect (client) {
|
||||
})
|
||||
|
||||
stream.once('close', (hadError) => {
|
||||
lazyReconnect(client, 'close')
|
||||
if (reconnect === undefined) reconnect = require('./reconnect')
|
||||
reconnect(client, 'close')
|
||||
})
|
||||
|
||||
stream.once('end', () => {
|
||||
lazyReconnect(client, 'end')
|
||||
if (reconnect === undefined) reconnect = require('./reconnect')
|
||||
reconnect(client, 'end')
|
||||
})
|
||||
|
||||
if (options.tls) {
|
||||
|
Reference in New Issue
Block a user