@autofleet/node-common 1.5.1 → 1.6.1
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/.dependabot/config.yml +10 -0
- package/.github/workflows/main.yml +37 -0
- package/package.json +2 -2
- package/settings/index.js +3 -10
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
npm-test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v2
|
|
15
|
+
- uses: actions/setup-node@v1
|
|
16
|
+
with:
|
|
17
|
+
node-version: 12
|
|
18
|
+
registry-url: https://registry.npmjs.org/
|
|
19
|
+
- run: npm ci
|
|
20
|
+
- run: npm run linter
|
|
21
|
+
- run: npm run coverage
|
|
22
|
+
- run: rm -rf ./coverage
|
|
23
|
+
env:
|
|
24
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
25
|
+
|
|
26
|
+
publish-npm:
|
|
27
|
+
needs: npm-test
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v2
|
|
31
|
+
- uses: actions/setup-node@v1
|
|
32
|
+
with:
|
|
33
|
+
node-version: 12
|
|
34
|
+
registry-url: https://registry.npmjs.org/
|
|
35
|
+
- run: npm publish
|
|
36
|
+
env:
|
|
37
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/node-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
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": "^
|
|
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",
|
package/settings/index.js
CHANGED
|
@@ -2,7 +2,7 @@ const EventEmitter = require('events');
|
|
|
2
2
|
const NodeCache = require('node-cache');
|
|
3
3
|
const Network = require('../network');
|
|
4
4
|
const Logger = require('../logger');
|
|
5
|
-
const keysMap = require('./map');
|
|
5
|
+
// const keysMap = require('./map');
|
|
6
6
|
|
|
7
7
|
const util = require('util');
|
|
8
8
|
|
|
@@ -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.
|
|
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.
|
|
99
|
+
this.settingsCache.set(cacheKey, value, this.ttl);
|
|
107
100
|
}
|
|
108
101
|
|
|
109
102
|
flush() {
|