@imqueue/rpc 1.13.6 → 1.13.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imqueue/rpc",
3
- "version": "1.13.6",
3
+ "version": "1.13.11",
4
4
  "description": "RPC-like client-service implementation over messaging queue",
5
5
  "keywords": [
6
6
  "redis",
@@ -38,33 +38,33 @@
38
38
  "author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
39
39
  "license": "ISC",
40
40
  "dependencies": {
41
- "@imqueue/core": "^1.11.7",
41
+ "@imqueue/core": "^1.11.9",
42
42
  "@types/acorn": "^4.0.6",
43
- "@types/node": "^16.7.10",
43
+ "@types/node": "^16.11.6",
44
44
  "acorn": "^8.5.0",
45
45
  "murmurhash-native": "^3.5.0",
46
46
  "node-machine-id": "^1.1.12",
47
47
  "reflect-metadata": "^0.1.13",
48
- "typescript": "^4.4.2"
48
+ "typescript": "^4.4.4"
49
49
  },
50
50
  "devDependencies": {
51
- "@types/chai": "^4.2.21",
51
+ "@types/chai": "^4.2.22",
52
52
  "@types/mocha": "^9.0.0",
53
53
  "@types/mock-require": "^2.0.0",
54
- "@types/sinon": "^10.0.2",
54
+ "@types/sinon": "^10.0.6",
55
55
  "chai": "^4.3.4",
56
56
  "codeclimate-test-reporter": "^0.5.1",
57
57
  "coveralls": "^3.1.1",
58
58
  "minimist": ">=1.2.2",
59
- "mocha": "^9.1.1",
59
+ "mocha": "^9.1.3",
60
60
  "mocha-lcov-reporter": "^1.3.0",
61
61
  "mock-require": "^3.0.3",
62
62
  "nyc": "^15.1.0",
63
- "open": "^8.2.1",
63
+ "open": "^8.4.0",
64
64
  "sinon": "^11.1.2",
65
- "source-map-support": "^0.5.19",
66
- "ts-node": "^10.2.1",
67
- "typedoc": "^0.21.9"
65
+ "source-map-support": "^0.5.20",
66
+ "ts-node": "^10.4.0",
67
+ "typedoc": "^0.22.7"
68
68
  },
69
69
  "main": "index.js",
70
70
  "typescript": {
package/src/IMQClient.js CHANGED
@@ -175,7 +175,7 @@ class IMQClient extends events_1.EventEmitter {
175
175
  // interface
176
176
  this.emit(message.request.method, message);
177
177
  }
178
- const [resolve, reject] = this.resolvers[message.to];
178
+ const [resolve, reject] = this.resolvers[message.to] || [];
179
179
  // make sure no memory leaking
180
180
  delete this.resolvers[message.to];
181
181
  if (message.error) {
@@ -28,12 +28,7 @@ export declare const DEFAULT_REDIS_CACHE_OPTIONS: {
28
28
  port?: number | undefined;
29
29
  vendor?: string | undefined;
30
30
  logger?: ILogger | undefined;
31
- watcherCheckDelay?: number | undefined; /**
32
- * Returns value stored in cache by a given key
33
- *
34
- * @param {string} key
35
- * @returns {Promise<any>}
36
- */
31
+ watcherCheckDelay?: number | undefined;
37
32
  useGzip?: boolean | undefined;
38
33
  safeDelivery?: boolean | undefined;
39
34
  safeDeliveryTtl?: number | undefined;
@@ -78,7 +73,7 @@ export declare class RedisCache implements ICache {
78
73
  * Stores in cache given value under given key. If TTL is specified,
79
74
  * cached value will expire in a given number of milliseconds. If NX
80
75
  * argument set to true will create key:value in cache only if it does
81
- * not exists yet. Given value could be any JSON-compatible object and
76
+ * not exist yet. Given value could be any JSON-compatible object and
82
77
  * will be serialized automatically.
83
78
  *
84
79
  * @param {string} key
@@ -36,7 +36,12 @@ class RedisCache {
36
36
  RedisCache.redis = core_1.redis.createClient(Number(this.options.port), String(this.options.host));
37
37
  RedisCache.redis.on('ready', async () => {
38
38
  this.logger.info('%s: redis cache connected, host %s:%s, pid %s', this.name, this.options.host, this.options.port, process.pid);
39
- await RedisCache.redis.client('setname', `${this.options.prefix}:${this.name}:pid:${process.pid}:host:${os.hostname()}`);
39
+ try {
40
+ await RedisCache.redis.client('setname', `${this.options.prefix}:${this.name}:pid:${process.pid}:host:${os.hostname()}`);
41
+ }
42
+ catch (err) {
43
+ this.logger.warn('Redis client command error:', err);
44
+ }
40
45
  this.ready = true;
41
46
  resolve(this);
42
47
  });
@@ -67,6 +72,7 @@ class RedisCache {
67
72
  if (!RedisCache.redis) {
68
73
  throw new TypeError(exports.REDIS_CLIENT_INIT_ERROR);
69
74
  }
75
+ // noinspection ES6RedundantAwait
70
76
  const data = await RedisCache.redis.get(this.key(key));
71
77
  if (data) {
72
78
  return JSON.parse(data);
@@ -77,7 +83,7 @@ class RedisCache {
77
83
  * Stores in cache given value under given key. If TTL is specified,
78
84
  * cached value will expire in a given number of milliseconds. If NX
79
85
  * argument set to true will create key:value in cache only if it does
80
- * not exists yet. Given value could be any JSON-compatible object and
86
+ * not exist yet. Given value could be any JSON-compatible object and
81
87
  * will be serialized automatically.
82
88
  *
83
89
  * @param {string} key
@@ -125,6 +131,7 @@ class RedisCache {
125
131
  throw new TypeError(exports.REDIS_CLIENT_INIT_ERROR);
126
132
  }
127
133
  try {
134
+ // noinspection SpellCheckingInspection
128
135
  await RedisCache.redis.eval(`for _,k in ipairs(redis.call('keys','${keyMask}')) do redis.call('del',k) end`, 0);
129
136
  return true;
130
137
  }