@autofleet/node-common 1.5.1 → 1.6.0

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": "@autofleet/node-common",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "coverage": "jest --coverage --forceExit --runInBand",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "homepage": "https://github.com/Autofleet/node-common",
25
25
  "dependencies": {
26
- "@google-cloud/logging-winston": "^3.0.2",
26
+ "@google-cloud/logging-winston": "^0.10.2",
27
27
  "@google-cloud/pubsub": "^0.20.1",
28
28
  "axios": "^0.18.0",
29
29
  "axios-retry": "^3.1.0",
@@ -37,6 +37,7 @@
37
37
  "portfinder": "^1.0.13",
38
38
  "qs": "^6.5.2",
39
39
  "timekeeper": "^2.1.2",
40
+ "weak": "^1.0.1",
40
41
  "winston": "^3.0.0",
41
42
  "ws": "^5.2.1"
42
43
  },
package/settings/index.js CHANGED
@@ -45,17 +45,10 @@ class SettingsManager {
45
45
  });
46
46
  }
47
47
 
48
- calcRandomTtl() {
49
- return this.ttl + (1 + Math.random());
50
- }
51
-
52
48
  async get(key, defaultValue, labels = [], { timeout = 1000 } = {}) {
53
49
  if (typeof defaultValue === 'undefined') {
54
50
  throw new Error('Can\'t get a key without defaultValue');
55
51
  }
56
- if (!keysMap[key]) {
57
- logger.error(`Try to get settings for unknown key: ${key}`);
58
- }
59
52
 
60
53
  const cacheKey = `${key}_${JSON.stringify(labels)}`;
61
54
  const cacheValue = this.settingsCache.get(cacheKey);
@@ -97,13 +90,13 @@ class SettingsManager {
97
90
  this.settingsCache.del(cacheKey);
98
91
  throw e;
99
92
  }
100
- this.settingsCache.set(cacheKey, returnValue, this.calcRandomTtl());
93
+ this.settingsCache.set(cacheKey, returnValue, this.ttl);
101
94
  return returnValue;
102
95
  }
103
96
 
104
97
  setLocal(key, labels, value) {
105
98
  const cacheKey = `${key}_${JSON.stringify(labels)}`;
106
- this.settingsCache.set(cacheKey, value, this.calcRandomTtl());
99
+ this.settingsCache.set(cacheKey, value, this.ttl);
107
100
  }
108
101
 
109
102
  flush() {