@mimik/configuration 5.0.5 → 5.0.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/README.md +5 -4
- package/index.js +29 -24
- package/lib/common.js +3 -5
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -199,8 +199,9 @@ When `redis` is used the following environement variables are used for the confi
|
|
|
199
199
|
|
|
200
200
|
| Env variable name | Description | Default | Comments |
|
|
201
201
|
| ----------------- | ----------- | ------- | -------- |
|
|
202
|
-
| CACHE_IP | domain of the redis server to use | localhost:6379 |
|
|
203
|
-
|
|
|
202
|
+
| CACHE_IP | domain of the redis server to use with port | localhost:6379 |
|
|
203
|
+
| CACHE_USER | redis user if the redis service is auth protected | null |
|
|
204
|
+
| CACHE_PASSWORD | redis password for the user if the redis service is auth protected | null |
|
|
204
205
|
| CACHE_CONNECTION_TIMEOUT | time the server will wait at start to connect to the cache | 30 | in seconds
|
|
205
206
|
| CACHE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms
|
|
206
207
|
| CACHE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
|
|
@@ -211,8 +212,8 @@ When `redis` is used the following environement variables are used for the confi
|
|
|
211
212
|
| REDIS_RECONNECT_INTERVAL | time to wait before retry | 500 | in milliseconds
|
|
212
213
|
| REDIS_REQUEST_MAX_MEMORY | maximum memory size of the request cache | 10 | in megabytes
|
|
213
214
|
| REDIS_REQUEST_MAX_MEMORY_POLICY | eviction policy of the request cache | allkeys-lru |
|
|
214
|
-
| REDIS_SOCKET_KEEPALIVE | keep alive for
|
|
215
|
-
|
|
|
215
|
+
| REDIS_SOCKET_KEEPALIVE | keep long running connections alive for x seconds | 5000 | in seconds
|
|
216
|
+
| REDIS_DISABLE_OFFLINE_QUEUE | queuing event when not connected | no |
|
|
216
217
|
|
|
217
218
|
**Requires**: <code>module:@mimik/sumologic-winston-logger</code>
|
|
218
219
|
|
package/index.js
CHANGED
|
@@ -35,7 +35,6 @@ const {
|
|
|
35
35
|
DEFAULT_CLOUD_PROVIDER,
|
|
36
36
|
DEFAULT_CUSTOMER_CODE,
|
|
37
37
|
DEFAULT_CACHE_IP,
|
|
38
|
-
DEFAULT_CACHE_PASSWORD,
|
|
39
38
|
DEFAULT_CACHE_CONNECTION_TIMEOUT,
|
|
40
39
|
DEFAULT_CACHE_RECONNECTION_OFFSET,
|
|
41
40
|
DEFAULT_CACHE_VALIDATION_CHECK,
|
|
@@ -47,7 +46,7 @@ const {
|
|
|
47
46
|
DEFAULT_REDIS_REQUEST_MAX_MEMORY,
|
|
48
47
|
DEFAULT_REDIS_REQUEST_MAX_MEMORY_POLICY,
|
|
49
48
|
DEFAULT_REDIS_SOCKET_KEEPALIVE,
|
|
50
|
-
|
|
49
|
+
DEFAULT_REDIS_DISABLE_OFFLINE_QUEUE,
|
|
51
50
|
DEFAULT_AWS_REGION,
|
|
52
51
|
DEFAULT_AWS_LOCAL_PROPERTIES,
|
|
53
52
|
DEFAULT_DYNAMODB_LOCAL_URL,
|
|
@@ -104,37 +103,42 @@ const isMSTSet = process.env.MST_SET !== SET_OFF;
|
|
|
104
103
|
|
|
105
104
|
const setupRedis = () => {
|
|
106
105
|
const domain = process.env.CACHE_IP || DEFAULT_CACHE_IP;
|
|
107
|
-
const
|
|
106
|
+
const username = process.env.CACHE_USER;
|
|
107
|
+
const password = process.env.CACHE_PASSWORD;
|
|
108
108
|
const reconnectTries = parseInt(process.env.REDIS_RECONNECT_TRIES, 10) || DEFAULT_REDIS_RECONNECT_TRIES;
|
|
109
109
|
const reconnectInterval = parseInt(process.env.REDIS_RECONNECT_INTERVAL, 10) || DEFAULT_REDIS_RECONNECT_INTERVAL;
|
|
110
|
-
let url =
|
|
110
|
+
let url = REDIS_BASE_URL;
|
|
111
|
+
if (username && password) url += `${username}:${password}@`;
|
|
112
|
+
url += domain;
|
|
111
113
|
|
|
112
|
-
if (password) url = `${url}?password=${password}`;
|
|
113
114
|
return {
|
|
114
115
|
domain,
|
|
116
|
+
username,
|
|
115
117
|
password,
|
|
116
118
|
connectTimeout: parseInt(process.env.CACHE_CONNECTION_TIMEOUT, 10) || DEFAULT_CACHE_CONNECTION_TIMEOUT,
|
|
117
119
|
validationCheck: parseInt(process.env.CACHE_VALIDATION_CHECK, 10) || DEFAULT_CACHE_VALIDATION_CHECK,
|
|
118
120
|
reconnectOffset: parseInt(process.env.CACHE_RECONNECTION_OFFSET, 10) || DEFAULT_CACHE_RECONNECTION_OFFSET,
|
|
119
121
|
url,
|
|
120
122
|
options: {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
socket: {
|
|
124
|
+
keepAlive: process.env.REDIS_SOCKET_KEEPALIVE || DEFAULT_REDIS_SOCKET_KEEPALIVE,
|
|
125
|
+
reconnectStrategy: function retryStrategy(opts) {
|
|
126
|
+
if (opts.timesConnected > 0 && opts.attempt < reconnectTries) {
|
|
127
|
+
return reconnectInterval;
|
|
128
|
+
}
|
|
129
|
+
if (opts.error && opts.error.code === 'ECONNREFUSED') {
|
|
130
|
+
if (display) {
|
|
131
|
+
logger.error('Fatal error: Could not connect to cache', { type: 'redis', error: opts.error.code }, `redis-cache-start@0/${new Date().toISOString()}`);
|
|
132
|
+
logger.flushAndExit(1);
|
|
133
|
+
}
|
|
134
|
+
display = false;
|
|
133
135
|
}
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
136
|
+
return undefined;
|
|
137
|
+
},
|
|
138
|
+
disableOfflineQueue: (process.env.REDIS_DISABLE_OFFLINE_QUEUE === 'yes') || DEFAULT_REDIS_DISABLE_OFFLINE_QUEUE,
|
|
137
139
|
},
|
|
140
|
+
maxMemory: process.env.REDIS_REQUEST_MAX_MEMORY || DEFAULT_REDIS_REQUEST_MAX_MEMORY,
|
|
141
|
+
maxMemoryPolicy: process.env.REDIS_REQUEST_MAX_MEMORY_POLICY || DEFAULT_REDIS_REQUEST_MAX_MEMORY_POLICY,
|
|
138
142
|
},
|
|
139
143
|
retryStrategyOptions: {
|
|
140
144
|
reconnectTries,
|
|
@@ -642,8 +646,9 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
642
646
|
*
|
|
643
647
|
* | Env variable name | Description | Default | Comments |
|
|
644
648
|
* | ----------------- | ----------- | ------- | -------- |
|
|
645
|
-
* | CACHE_IP | domain of the redis server to use | localhost:6379 |
|
|
646
|
-
* |
|
|
649
|
+
* | CACHE_IP | domain of the redis server to use with port | localhost:6379 |
|
|
650
|
+
* | CACHE_USER | redis user if the redis service is auth protected | null |
|
|
651
|
+
* | CACHE_PASSWORD | redis password for the user if the redis service is auth protected | null |
|
|
647
652
|
* | CACHE_CONNECTION_TIMEOUT | time the server will wait at start to connect to the cache | 30 | in seconds
|
|
648
653
|
* | CACHE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms
|
|
649
654
|
* | CACHE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
|
|
@@ -654,8 +659,8 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
654
659
|
* | REDIS_RECONNECT_INTERVAL | time to wait before retry | 500 | in milliseconds
|
|
655
660
|
* | REDIS_REQUEST_MAX_MEMORY | maximum memory size of the request cache | 10 | in megabytes
|
|
656
661
|
* | REDIS_REQUEST_MAX_MEMORY_POLICY | eviction policy of the request cache | allkeys-lru |
|
|
657
|
-
* | REDIS_SOCKET_KEEPALIVE | keep alive for
|
|
658
|
-
* |
|
|
662
|
+
* | REDIS_SOCKET_KEEPALIVE | keep long running connections alive for x seconds | 5000 | in seconds
|
|
663
|
+
* | REDIS_DISABLE_OFFLINE_QUEUE | queuing event when not connected | no |
|
|
659
664
|
*/
|
|
660
665
|
const setConfig = (pack, options) => {
|
|
661
666
|
process.env.SERVER_VERSION = pack.version;
|
package/lib/common.js
CHANGED
|
@@ -21,7 +21,6 @@ const DEFAULT_CLOUD_PROVIDER = 'noCloud';
|
|
|
21
21
|
const DEFAULT_CUSTOMER_CODE = '';
|
|
22
22
|
|
|
23
23
|
const DEFAULT_CACHE_IP = 'localhost:6379';
|
|
24
|
-
const DEFAULT_CACHE_PASSWORD = null;
|
|
25
24
|
const DEFAULT_CACHE_CONNECTION_TIMEOUT = 30; // in seconds
|
|
26
25
|
const DEFAULT_CACHE_RECONNECTION_OFFSET = 5; // in seconds
|
|
27
26
|
const DEFAULT_CACHE_VALIDATION_CHECK = 1000; // in ms
|
|
@@ -33,8 +32,8 @@ const DEFAULT_REDIS_RECONNECT_TRIES = 100;
|
|
|
33
32
|
const DEFAULT_REDIS_RECONNECT_INTERVAL = 500; // in ms
|
|
34
33
|
const DEFAULT_REDIS_REQUEST_MAX_MEMORY = '10mb';
|
|
35
34
|
const DEFAULT_REDIS_REQUEST_MAX_MEMORY_POLICY = 'allkeys-lru';
|
|
36
|
-
const DEFAULT_REDIS_SOCKET_KEEPALIVE =
|
|
37
|
-
const
|
|
35
|
+
const DEFAULT_REDIS_SOCKET_KEEPALIVE = 5000;
|
|
36
|
+
const DEFAULT_REDIS_DISABLE_OFFLINE_QUEUE = false;
|
|
38
37
|
|
|
39
38
|
const DEFAULT_AWS_REGION = '---noRegion--';
|
|
40
39
|
const DEFAULT_AWS_LOCAL_PROPERTIES = '169.254.169.254'; // to access properties of the instance on AWS
|
|
@@ -118,7 +117,6 @@ module.exports = {
|
|
|
118
117
|
DEFAULT_LOCATION_PROVIDER,
|
|
119
118
|
DEFAULT_CLOUD_PROVIDER,
|
|
120
119
|
DEFAULT_CACHE_IP,
|
|
121
|
-
DEFAULT_CACHE_PASSWORD,
|
|
122
120
|
DEFAULT_CACHE_CONNECTION_TIMEOUT,
|
|
123
121
|
DEFAULT_CACHE_RECONNECTION_OFFSET,
|
|
124
122
|
DEFAULT_CACHE_VALIDATION_CHECK,
|
|
@@ -130,7 +128,7 @@ module.exports = {
|
|
|
130
128
|
DEFAULT_REDIS_REQUEST_MAX_MEMORY,
|
|
131
129
|
DEFAULT_REDIS_REQUEST_MAX_MEMORY_POLICY,
|
|
132
130
|
DEFAULT_REDIS_SOCKET_KEEPALIVE,
|
|
133
|
-
|
|
131
|
+
DEFAULT_REDIS_DISABLE_OFFLINE_QUEUE,
|
|
134
132
|
DEFAULT_AWS_REGION,
|
|
135
133
|
DEFAULT_AWS_LOCAL_PROPERTIES,
|
|
136
134
|
DEFAULT_DYNAMODB_LOCAL_URL,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/configuration",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.6",
|
|
4
4
|
"description": "Common configuration for mimik services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"url": "https://bitbucket.org/mimiktech/configuration"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@mimik/request-helper": "^1.7.
|
|
34
|
-
"@mimik/sumologic-winston-logger": "^1.6.
|
|
33
|
+
"@mimik/request-helper": "^1.7.9",
|
|
34
|
+
"@mimik/sumologic-winston-logger": "^1.6.19",
|
|
35
35
|
"@mimik/user-filters": "1.3.6",
|
|
36
36
|
"ip": "2.0.0",
|
|
37
37
|
"lodash": "4.17.21",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@mimik/eslint-plugin-dependencies": "^2.4.5",
|
|
42
42
|
"@mimik/eslint-plugin-document-env": "^1.0.5",
|
|
43
|
-
"eslint": "8.
|
|
43
|
+
"eslint": "8.48.0",
|
|
44
44
|
"eslint-config-airbnb": "19.0.4",
|
|
45
|
-
"eslint-plugin-import": "2.
|
|
45
|
+
"eslint-plugin-import": "2.28.1",
|
|
46
46
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
47
|
-
"eslint-plugin-react": "7.
|
|
47
|
+
"eslint-plugin-react": "7.33.2",
|
|
48
48
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
49
49
|
"husky": "8.0.3",
|
|
50
50
|
"jsdoc-to-markdown": "8.0.0"
|