1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

feat: add auto pipeline

This commit is contained in:
Ruben Bridgewater
2017-05-28 04:31:37 +02:00
parent 8c63233968
commit 0d53d3dcdf
8 changed files with 79 additions and 121 deletions

View File

@ -6,7 +6,6 @@ var lazyConnect = function (client) {
lazyConnect = require('./connect')
lazyConnect(client)
}
const noop = () => {}
/**
* @description Try connecting to a server again
@ -50,10 +49,6 @@ function reconnect (client, why, error) {
debug('Redis connection is gone from %s event.', why)
client.connected = false
client.ready = false
// Deactivate cork to work with the offline queue
client.cork = noop
client.uncork = noop
client.pipeline = false
client.pubSubMode = 0
// since we are collapsing end and close, users don't expect to be called twice
@ -108,10 +103,13 @@ function reconnect (client, why, error) {
if (client.options.retryUnfulfilledCommands) {
client.offlineQueue.unshift.apply(client.offlineQueue, client.commandQueue.toArray())
client.commandQueue.clear()
} else if (client.commandQueue.length !== 0) {
// TODO: If only the pipelineQueue contains the error we could improve the situation.
// We could postpone writing to the stream until we connected again and fire the commands.
// The commands in the pipelineQueue are also not uncertain. They never left the client.
} else if (client.commandQueue.length !== 0 || client._pipelineQueue.length !== 0) {
client.flushAndError('Redis connection lost and command aborted.', 'UNCERTAIN_STATE', {
error,
queues: ['commandQueue']
queues: ['commandQueue', '_pipelineQueue']
})
}