@mimik/configuration 5.0.6 → 5.0.8

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.
Files changed (3) hide show
  1. package/README.md +6 -1
  2. package/index.js +16 -1
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -91,6 +91,8 @@ The following environement variables are being used for the configuration:
91
91
  | REQUEST_TIMEOUT | timeout for intra cluster http request | 10000 | cluster.timeout | in milliseconds
92
92
  | CACHE_SET | switch to enable use of cache | off | cache.set | can be `on`, `off`
93
93
  | TOPIC_SET | switch to enable use of event topic | off | topic.set | can be `on`, `off`, `mock`
94
+ | SET_SNS_TOPIC_FIFO | set to yes if fifo topic | no | topic.isFifoTopic | can be `yes`, `no`
95
+ | SET_SNS_CONTENT_DEDUPLICATION | set to yes, to use content based deduplication | no | contentBasedDeduplication | when fifo topic is used and set to no, MessageDeduplicationId must be provided in message.
94
96
  | ENCRYPTION_SET | switch to enable use of mongodb encryption | off | encryption.set | can be `on`, or `off`
95
97
  | MIT_URL | url for reaching mIT | | dependencies.mIT.url |
96
98
  | MIT_AUDIENCE | audience of mIT | | dependencies.mIT.audience | [2]
@@ -199,9 +201,12 @@ When `redis` is used the following environement variables are used for the confi
199
201
 
200
202
  | Env variable name | Description | Default | Comments |
201
203
  | ----------------- | ----------- | ------- | -------- |
202
- | CACHE_IP | domain of the redis server to use with port | localhost:6379 |
204
+ | CACHE_IP | domain of the redis server to use with port, a comma seperated list if using cluster | localhost:6379 |
203
205
  | CACHE_USER | redis user if the redis service is auth protected | null |
204
206
  | CACHE_PASSWORD | redis password for the user if the redis service is auth protected | null |
207
+ | CACHE_CLUSTER_SET | set on, when using redis in a cluster. | off |
208
+ | CACHE_CLUSTER_USE_REPLICAS | When set on, distribute load by executing readonly commands (such as GET) across all cluster nodes. When false, only use master nodes | off |
209
+ | CACHE_CLUSTER_MINIMIZE_CONNECTION | When set on, .connect() will only discover the cluster topology, without actually connecting to all the nodes. Useful for short-term or Pub/Sub-only connections. | off |
205
210
  | CACHE_CONNECTION_TIMEOUT | time the server will wait at start to connect to the cache | 30 | in seconds
206
211
  | CACHE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms
207
212
  | CACHE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
package/index.js CHANGED
@@ -111,6 +111,12 @@ const setupRedis = () => {
111
111
  if (username && password) url += `${username}:${password}@`;
112
112
  url += domain;
113
113
 
114
+ const clusterConfig = {
115
+ set: process.env.CACHE_CLUSTER_SET || SET_OFF,
116
+ useReplicas: process.env.CACHE_CLUSTER_USE_REPLICAS || SET_OFF,
117
+ minimizeConnections: process.env.CACHE_CLUSTER_MINIMIZE_CONNECTION || SET_OFF,
118
+ };
119
+
114
120
  return {
115
121
  domain,
116
122
  username,
@@ -119,6 +125,7 @@ const setupRedis = () => {
119
125
  validationCheck: parseInt(process.env.CACHE_VALIDATION_CHECK, 10) || DEFAULT_CACHE_VALIDATION_CHECK,
120
126
  reconnectOffset: parseInt(process.env.CACHE_RECONNECTION_OFFSET, 10) || DEFAULT_CACHE_RECONNECTION_OFFSET,
121
127
  url,
128
+ cluster: clusterConfig,
122
129
  options: {
123
130
  socket: {
124
131
  keepAlive: process.env.REDIS_SOCKET_KEEPALIVE || DEFAULT_REDIS_SOCKET_KEEPALIVE,
@@ -291,8 +298,11 @@ const setupTopic = (topicOpts) => {
291
298
  const topicConfig = {
292
299
  region: process.env.SNS_AWS_REGION || DEFAULT_AWS_REGION,
293
300
  name: topicOpts.name,
301
+ isFifoTopic: process.env.SET_SNS_TOPIC_FIFO === 'yes',
302
+ contentBasedDeduplication: false,
294
303
  };
295
304
 
305
+ if (topicConfig.isFifoTopic) topicConfig.contentBasedDeduplication = process.env.SET_SNS_CONTENT_DEDUPLICATION === 'yes';
296
306
  if (!_.isNil(process.env.SNS_AWS_ACCESS_KEY_ID)) topicConfig.accessKeyId = process.env.SNS_AWS_ACCESS_KEY_ID;
297
307
  if (!_.isNil(process.env.SNS_AWS_SECRET_ACCESS_KEY)) topicConfig.secretAccessKey = process.env.SNS_AWS_SECRET_ACCESS_KEY;
298
308
 
@@ -538,6 +548,8 @@ configuration.locationProvider = setupLocationProvider();
538
548
  * | REQUEST_TIMEOUT | timeout for intra cluster http request | 10000 | cluster.timeout | in milliseconds
539
549
  * | CACHE_SET | switch to enable use of cache | off | cache.set | can be `on`, `off`
540
550
  * | TOPIC_SET | switch to enable use of event topic | off | topic.set | can be `on`, `off`, `mock`
551
+ * | SET_SNS_TOPIC_FIFO | set to yes if fifo topic | no | topic.isFifoTopic | can be `yes`, `no`
552
+ * | SET_SNS_CONTENT_DEDUPLICATION | set to yes, to use content based deduplication | no | contentBasedDeduplication | when fifo topic is used and set to no, MessageDeduplicationId must be provided in message.
541
553
  * | ENCRYPTION_SET | switch to enable use of mongodb encryption | off | encryption.set | can be `on`, or `off`
542
554
  * | MIT_URL | url for reaching mIT | | dependencies.mIT.url |
543
555
  * | MIT_AUDIENCE | audience of mIT | | dependencies.mIT.audience | [2]
@@ -646,9 +658,12 @@ configuration.locationProvider = setupLocationProvider();
646
658
  *
647
659
  * | Env variable name | Description | Default | Comments |
648
660
  * | ----------------- | ----------- | ------- | -------- |
649
- * | CACHE_IP | domain of the redis server to use with port | localhost:6379 |
661
+ * | CACHE_IP | domain of the redis server to use with port, a comma seperated list if using cluster | localhost:6379 |
650
662
  * | CACHE_USER | redis user if the redis service is auth protected | null |
651
663
  * | CACHE_PASSWORD | redis password for the user if the redis service is auth protected | null |
664
+ * | CACHE_CLUSTER_SET | set on, when using redis in a cluster. | off |
665
+ * | CACHE_CLUSTER_USE_REPLICAS | When set on, distribute load by executing readonly commands (such as GET) across all cluster nodes. When false, only use master nodes | off |
666
+ * | CACHE_CLUSTER_MINIMIZE_CONNECTION | When set on, .connect() will only discover the cluster topology, without actually connecting to all the nodes. Useful for short-term or Pub/Sub-only connections. | off |
652
667
  * | CACHE_CONNECTION_TIMEOUT | time the server will wait at start to connect to the cache | 30 | in seconds
653
668
  * | CACHE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms
654
669
  * | CACHE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimik/configuration",
3
- "version": "5.0.6",
3
+ "version": "5.0.8",
4
4
  "description": "Common configuration for mimik services",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,15 +35,15 @@
35
35
  "@mimik/user-filters": "1.3.6",
36
36
  "ip": "2.0.0",
37
37
  "lodash": "4.17.21",
38
- "uuid": "9.0.0"
38
+ "uuid": "9.0.1"
39
39
  },
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.48.0",
43
+ "eslint": "8.54.0",
44
44
  "eslint-config-airbnb": "19.0.4",
45
- "eslint-plugin-import": "2.28.1",
46
- "eslint-plugin-jsx-a11y": "6.7.1",
45
+ "eslint-plugin-import": "2.29.0",
46
+ "eslint-plugin-jsx-a11y": "6.8.0",
47
47
  "eslint-plugin-react": "7.33.2",
48
48
  "eslint-plugin-react-hooks": "4.6.0",
49
49
  "husky": "8.0.3",