@redis/client
Advanced tools
Comparing version 1.5.6 to 1.5.7
@@ -13,3 +13,3 @@ "use strict"; | ||
}; | ||
var _RedisClient_instances, _RedisClient_options, _RedisClient_socket, _RedisClient_queue, _RedisClient_isolationPool, _RedisClient_v4, _RedisClient_selectedDB, _RedisClient_initiateOptions, _RedisClient_initiateQueue, _RedisClient_initiateSocket, _RedisClient_legacyMode, _RedisClient_legacySendCommand, _RedisClient_defineLegacyCommand, _RedisClient_pingTimer, _RedisClient_setPingTimer, _RedisClient_sendCommand, _RedisClient_pubSubCommand, _RedisClient_tick, _RedisClient_addMultiCommands, _RedisClient_destroyIsolationPool; | ||
var _RedisClient_instances, _RedisClient_options, _RedisClient_socket, _RedisClient_queue, _RedisClient_isolationPool, _RedisClient_v4, _RedisClient_selectedDB, _RedisClient_initiateOptions, _RedisClient_initiateQueue, _RedisClient_initiateSocket, _RedisClient_initiateIsolationPool, _RedisClient_legacyMode, _RedisClient_legacySendCommand, _RedisClient_defineLegacyCommand, _RedisClient_pingTimer, _RedisClient_setPingTimer, _RedisClient_sendCommand, _RedisClient_pubSubCommand, _RedisClient_tick, _RedisClient_addMultiCommands, _RedisClient_destroyIsolationPool; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -171,12 +171,5 @@ const commands_1 = require("./commands"); | ||
__classPrivateFieldSet(this, _RedisClient_socket, __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_initiateSocket).call(this), "f"); | ||
__classPrivateFieldSet(this, _RedisClient_isolationPool, (0, generic_pool_1.createPool)({ | ||
create: async () => { | ||
const duplicate = this.duplicate({ | ||
isolationPoolOptions: undefined | ||
}).on('error', err => this.emit('error', err)); | ||
await duplicate.connect(); | ||
return duplicate; | ||
}, | ||
destroy: client => client.disconnect() | ||
}, options?.isolationPoolOptions), "f"); | ||
// should be initiated in connect, not here | ||
// TODO: consider breaking in v5 | ||
__classPrivateFieldSet(this, _RedisClient_isolationPool, __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_initiateIsolationPool).call(this), "f"); | ||
__classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_legacyMode).call(this); | ||
@@ -191,2 +184,4 @@ } | ||
connect() { | ||
// see comment in constructor | ||
__classPrivateFieldSet(this, _RedisClient_isolationPool, __classPrivateFieldGet(this, _RedisClient_isolationPool, "f") ?? __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_initiateIsolationPool).call(this), "f"); | ||
return __classPrivateFieldGet(this, _RedisClient_socket, "f").connect(); | ||
@@ -277,2 +272,4 @@ } | ||
executeIsolated(fn) { | ||
if (!__classPrivateFieldGet(this, _RedisClient_isolationPool, "f")) | ||
return Promise.reject(new errors_1.ClientClosedError()); | ||
return __classPrivateFieldGet(this, _RedisClient_isolationPool, "f").use(fn); | ||
@@ -418,2 +415,13 @@ } | ||
.on('end', () => this.emit('end')); | ||
}, _RedisClient_initiateIsolationPool = function _RedisClient_initiateIsolationPool() { | ||
return (0, generic_pool_1.createPool)({ | ||
create: async () => { | ||
const duplicate = this.duplicate({ | ||
isolationPoolOptions: undefined | ||
}).on('error', err => this.emit('error', err)); | ||
await duplicate.connect(); | ||
return duplicate; | ||
}, | ||
destroy: client => client.disconnect() | ||
}, __classPrivateFieldGet(this, _RedisClient_options, "f")?.isolationPoolOptions); | ||
}, _RedisClient_legacyMode = function _RedisClient_legacyMode() { | ||
@@ -522,2 +530,3 @@ var _a, _b; | ||
await __classPrivateFieldGet(this, _RedisClient_isolationPool, "f").clear(); | ||
__classPrivateFieldSet(this, _RedisClient_isolationPool, undefined, "f"); | ||
}; | ||
@@ -524,0 +533,0 @@ (0, commander_1.attachCommands)({ |
@@ -287,3 +287,3 @@ "use strict"; | ||
__classPrivateFieldGet(this, _PubSub_listeners, "f")[PubSubType.PATTERNS].size !== 0 || | ||
__classPrivateFieldGet(this, _PubSub_listeners, "f")[PubSubType.CHANNELS].size !== 0 || | ||
__classPrivateFieldGet(this, _PubSub_listeners, "f")[PubSubType.SHARDED].size !== 0 || | ||
__classPrivateFieldGet(this, _PubSub_subscribing, "f") !== 0), "f"); | ||
@@ -290,0 +290,0 @@ }, _PubSub_emitPubSubMessage = function _PubSub_emitPubSubMessage(type, message, channel, pattern) { |
@@ -194,3 +194,3 @@ "use strict"; | ||
.once('close', hadError => { | ||
if (!hadError && __classPrivateFieldGet(this, _RedisSocket_isOpen, "f") && __classPrivateFieldGet(this, _RedisSocket_socket, "f") === socket) { | ||
if (!hadError && __classPrivateFieldGet(this, _RedisSocket_isReady, "f") && __classPrivateFieldGet(this, _RedisSocket_socket, "f") === socket) { | ||
__classPrivateFieldGet(this, _RedisSocket_instances, "m", _RedisSocket_onSocketError).call(this, new errors_1.SocketClosedUnexpectedlyError()); | ||
@@ -197,0 +197,0 @@ } |
@@ -125,4 +125,4 @@ "use strict"; | ||
async commandsExecutor(command, args) { | ||
const { args: redisArgs, options } = (0, commander_1.transformCommandArguments)(command, args); | ||
return (0, commander_1.transformCommandReply)(command, await this.sendCommand(RedisCluster.extractFirstKey(command, args, redisArgs), command.IS_READ_ONLY, redisArgs, options), redisArgs.preserve); | ||
const { jsArgs, args: redisArgs, options } = (0, commander_1.transformCommandArguments)(command, args); | ||
return (0, commander_1.transformCommandReply)(command, await this.sendCommand(RedisCluster.extractFirstKey(command, jsArgs, redisArgs), command.IS_READ_ONLY, redisArgs, options), redisArgs.preserve); | ||
} | ||
@@ -129,0 +129,0 @@ async sendCommand(firstKey, isReadonly, args, options) { |
@@ -23,2 +23,3 @@ import { ClientCommandOptions } from './client'; | ||
export declare function transformCommandArguments<T = ClientCommandOptions>(command: RedisCommand, args: Array<unknown>): { | ||
jsArgs: Array<unknown>; | ||
args: RedisCommandArguments; | ||
@@ -25,0 +26,0 @@ options: CommandOptions<T> | undefined; |
@@ -71,2 +71,3 @@ "use strict"; | ||
return { | ||
jsArgs: args, | ||
args: command.transformArguments(...args), | ||
@@ -73,0 +74,0 @@ options |
{ | ||
"name": "@redis/client", | ||
"version": "1.5.6", | ||
"version": "1.5.7", | ||
"license": "MIT", | ||
@@ -48,3 +48,6 @@ "main": "./dist/index.js", | ||
}, | ||
"homepage": "https://github.com/redis/node-redis/tree/master/packages/client" | ||
"homepage": "https://github.com/redis/node-redis/tree/master/packages/client", | ||
"keywords": [ | ||
"redis" | ||
] | ||
} |
586813
13069