@hotmeshio/hotmesh 0.1.4 → 0.1.6

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -48,7 +48,7 @@
48
48
  "test:interrupt": "NODE_ENV=test jest ./tests/functional/interrupt/index.test.ts --detectOpenHandles --forceExit --verbose",
49
49
  "test:parallel": "NODE_ENV=test jest ./tests/functional/parallel/index.test.ts --detectOpenHandles --forceExit --verbose",
50
50
  "test:pipe": "NODE_ENV=test jest ./tests/unit/services/pipe/index.test.ts --detectOpenHandles --forceExit --verbose",
51
- "test:quorum": "NODE_ENV=test jest ./tests/functional/quorum/index.test.ts --detectOpenHandles --forceExit --verbose",
51
+ "test:quorum": "HMSH_IS_CLUSTER=true NODE_ENV=test jest ./tests/functional/quorum/index.test.ts --detectOpenHandles --forceExit --verbose",
52
52
  "test:reclaim": "NODE_ENV=test jest ./tests/functional/reclaim/index.test.ts --detectOpenHandles --forceExit --verbose",
53
53
  "test:redeploy": "NODE_ENV=test jest ./tests/functional/redeploy/index.test.ts --detectOpenHandles --forceExit --verbose",
54
54
  "test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant/index.test.ts --detectOpenHandles --forceExit --verbose",
@@ -116,9 +116,9 @@ class EngineService {
116
116
  }
117
117
  }
118
118
  setCacheMode(cacheMode, untilVersion) {
119
- this.logger.info(`engine-cache-updated`, {
119
+ this.logger.info(`engine-executable-cache`, {
120
120
  mode: cacheMode,
121
- until: untilVersion,
121
+ [cacheMode === 'cache' ? 'target' : 'until']: untilVersion,
122
122
  });
123
123
  this.cacheMode = cacheMode;
124
124
  this.untilVersion = untilVersion;
@@ -112,7 +112,7 @@ class HotMeshService {
112
112
  if (options.guid) {
113
113
  throttleMessage.guid = options.guid;
114
114
  }
115
- else if (options.topic) {
115
+ if (options.topic !== undefined) {
116
116
  throttleMessage.topic = options.topic;
117
117
  }
118
118
  await this.engine.store.setThrottleRate(throttleMessage);
@@ -1010,15 +1010,18 @@ class StoreService {
1010
1010
  if (options.guid) {
1011
1011
  return;
1012
1012
  }
1013
- //if a topic, update
1013
+ //if a topic, update one
1014
+ const rate = options.throttle.toString();
1014
1015
  if (options.topic) {
1015
- await this.redisClient[this.commands.hset](key, options.topic, options.throttle.toString());
1016
+ await this.redisClient[this.commands.hset](key, {
1017
+ [options.topic]: rate,
1018
+ });
1016
1019
  }
1017
1020
  else {
1018
1021
  //if no topic, update all
1019
1022
  const multi = this.getMulti();
1020
1023
  multi[this.commands.del](key);
1021
- multi[this.commands.hset](key, ':', options.throttle.toString());
1024
+ multi[this.commands.hset](key, { ':': rate });
1022
1025
  await multi.exec();
1023
1026
  }
1024
1027
  }
@@ -1028,13 +1031,22 @@ class StoreService {
1028
1031
  return response ?? {};
1029
1032
  }
1030
1033
  async getThrottleRate(topic) {
1034
+ //always return a valid number range
1035
+ const resolveRate = (response, topic) => {
1036
+ const rate = topic in response ? Number(response[topic]) : 0;
1037
+ if (isNaN(rate))
1038
+ return 0;
1039
+ if (rate == -1)
1040
+ return enums_1.MAX_DELAY;
1041
+ return Math.max(Math.min(rate, enums_1.MAX_DELAY), 0);
1042
+ };
1031
1043
  const response = await this.getThrottleRates();
1032
- const rate = topic in response ? Number(response[topic]) : 0;
1033
- if (isNaN(rate))
1034
- return 0;
1035
- if (rate == -1)
1036
- return enums_1.MAX_DELAY;
1037
- return Math.max(Math.min(rate, enums_1.MAX_DELAY), 0);
1044
+ const globalRate = resolveRate(response, ':');
1045
+ if (topic === ':' || !(topic in response)) {
1046
+ //use global rate unless worker specifies rate
1047
+ return globalRate;
1048
+ }
1049
+ return resolveRate(response, topic);
1038
1050
  }
1039
1051
  }
1040
1052
  exports.StoreService = StoreService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -48,7 +48,7 @@
48
48
  "test:interrupt": "NODE_ENV=test jest ./tests/functional/interrupt/index.test.ts --detectOpenHandles --forceExit --verbose",
49
49
  "test:parallel": "NODE_ENV=test jest ./tests/functional/parallel/index.test.ts --detectOpenHandles --forceExit --verbose",
50
50
  "test:pipe": "NODE_ENV=test jest ./tests/unit/services/pipe/index.test.ts --detectOpenHandles --forceExit --verbose",
51
- "test:quorum": "NODE_ENV=test jest ./tests/functional/quorum/index.test.ts --detectOpenHandles --forceExit --verbose",
51
+ "test:quorum": "HMSH_IS_CLUSTER=true NODE_ENV=test jest ./tests/functional/quorum/index.test.ts --detectOpenHandles --forceExit --verbose",
52
52
  "test:reclaim": "NODE_ENV=test jest ./tests/functional/reclaim/index.test.ts --detectOpenHandles --forceExit --verbose",
53
53
  "test:redeploy": "NODE_ENV=test jest ./tests/functional/redeploy/index.test.ts --detectOpenHandles --forceExit --verbose",
54
54
  "test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant/index.test.ts --detectOpenHandles --forceExit --verbose",