@hotmeshio/hotmesh 0.1.5 → 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.
package/build/package.json
CHANGED
|
@@ -116,9 +116,9 @@ class EngineService {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
setCacheMode(cacheMode, untilVersion) {
|
|
119
|
-
this.logger.info(`engine-cache
|
|
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;
|
|
@@ -1013,7 +1013,9 @@ class StoreService {
|
|
|
1013
1013
|
//if a topic, update one
|
|
1014
1014
|
const rate = options.throttle.toString();
|
|
1015
1015
|
if (options.topic) {
|
|
1016
|
-
await this.redisClient[this.commands.hset](key, {
|
|
1016
|
+
await this.redisClient[this.commands.hset](key, {
|
|
1017
|
+
[options.topic]: rate,
|
|
1018
|
+
});
|
|
1017
1019
|
}
|
|
1018
1020
|
else {
|
|
1019
1021
|
//if no topic, update all
|
|
@@ -1029,13 +1031,22 @@ class StoreService {
|
|
|
1029
1031
|
return response ?? {};
|
|
1030
1032
|
}
|
|
1031
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
|
+
};
|
|
1032
1043
|
const response = await this.getThrottleRates();
|
|
1033
|
-
const
|
|
1034
|
-
if (
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
return
|
|
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);
|
|
1039
1050
|
}
|
|
1040
1051
|
}
|
|
1041
1052
|
exports.StoreService = StoreService;
|