Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!this._queue.length) {
this.resolve([]);
}
let pipelineSlot: number;
if (this.isCluster) {
// List of the first key for each command
const sampleKeys: string[] = [];
for (let i = 0; i < this._queue.length; i++) {
var keys = this._queue[i].getKeys();
if (keys.length) {
sampleKeys.push(keys[0]);
}
}
if (sampleKeys.length) {
pipelineSlot = generateMulti(sampleKeys);
if (pipelineSlot < 0) {
this.reject(
new Error("All keys in the pipeline should belong to the same slot")
);
return this.promise;
}
} else {
// Send the pipeline to a random node
pipelineSlot = (Math.random() * 16384) | 0;
}
}
// Check whether scripts exists
const scripts = [];
for (let i = 0; i < this._queue.length; ++i) {
var item = this._queue[i];
if (!this._queue.length) {
this.resolve([]);
}
var pipelineSlot, i;
if (this.isCluster) {
// List of the first key for each command
var sampleKeys = [];
for (i = 0; i < this._queue.length; i++) {
var keys = this._queue[i].getKeys();
if (keys.length) {
sampleKeys.push(keys[0]);
}
}
if (sampleKeys.length) {
pipelineSlot = calculateSlot.generateMulti(sampleKeys);
if (pipelineSlot < 0) {
this.reject(new Error('All keys in the pipeline should belong to the same slot'));
return this.promise;
}
} else {
// Send the pipeline to a random node
pipelineSlot = Math.random() * 16384 | 0;
}
}
// Check whether scripts exists
var scripts = [];
for (i = 0; i < this._queue.length; ++i) {
var item = this._queue[i];
if (this.isCluster && item.isCustomCommand) {
this.reject(new Error('Sending custom commands in pipeline is not supported in Cluster mode.'));