1
0
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:
Ruben Bridgewater
2017-05-26 23:34:28 +02:00
parent 3065e2e7be
commit 1f179ef791
7 changed files with 322 additions and 291 deletions

View File

@@ -3,6 +3,7 @@
const Queue = require('denque')
const utils = require('./utils')
const Command = require('./command')
const handleReply = utils.handleReply
/**
* @description Queues all transaction commands and checks if a queuing error
@@ -23,9 +24,6 @@ function pipelineTransactionCommand (multi, command, index) {
multi.errors.push(err)
return
}
// Keep track of who wants buffer responses:
// By the time the callback is called the command got the bufferArgs attribute attached
multi.wantsBuffers[index] = command.bufferArgs
tmp(null, reply)
}
return multi._client.internalSendCommand(command)
@@ -41,8 +39,10 @@ function pipelineTransactionCommand (multi, command, index) {
function multiCallback (multi, replies) {
if (replies) {
var i = 0
while (multi._queue.length !== 0) {
const command = multi._queue.shift()
const queue = multi._queue
const client = multi._client
while (queue.length !== 0) {
const command = queue.shift()
if (replies[i] instanceof Error) {
const match = replies[i].message.match(utils.errCode)
// LUA script could return user errors that don't behave like all other errors!
@@ -53,7 +53,7 @@ function multiCallback (multi, replies) {
command.callback(replies[i])
} else {
// If we asked for strings, even in detectBuffers mode, then return strings:
replies[i] = multi._client.handleReply(replies[i], command.command, multi.wantsBuffers[i])
replies[i] = handleReply(client, replies[i], command)
command.callback(null, replies[i])
}
i++