ac-bootstrap-bull 1.0.12 → 1.0.14

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/CHANGELOG.md +20 -0
  2. package/index.js +17 -5
  3. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ <a name="1.0.14"></a>
2
+
3
+ ## [1.0.14](https://github.com/admiralcloud/ac-bootstrap-bull/compare/v1.0.13..v1.0.14) (2023-01-28 18:43:55)
4
+
5
+
6
+ ### Bug Fix
7
+
8
+ * **App:** Fixed error handling | MP | [acbaad1bbbe881bba5f61ffe54cd1df3952dc78b](https://github.com/admiralcloud/ac-bootstrap-bull/commit/acbaad1bbbe881bba5f61ffe54cd1df3952dc78b)
9
+ Improved retry strategy and improved error handling for Redis clients
10
+ Related issues: [undefined/undefined#master](undefined/browse/master)
11
+ <a name="1.0.13"></a>
12
+
13
+ ## [1.0.13](https://github.com/admiralcloud/ac-bootstrap-bull/compare/v1.0.12..v1.0.13) (2023-01-28 17:59:43)
14
+
15
+
16
+ ### Bug Fix
17
+
18
+ * **App:** Package updates | MP | [b81eefaebaeb2f2e988ef59320720db8583f43ab](https://github.com/admiralcloud/ac-bootstrap-bull/commit/b81eefaebaeb2f2e988ef59320720db8583f43ab)
19
+ Package updates
20
+ Related issues: [undefined/undefined#master](undefined/browse/master)
1
21
  <a name="1.0.12"></a>
2
22
 
3
23
  ## [1.0.12](https://github.com/admiralcloud/ac-bootstrap-bull/compare/v1.0.11..v1.0.12) (2022-12-13 17:55:28)
package/index.js CHANGED
@@ -43,8 +43,9 @@ module.exports = function(acapi) {
43
43
  port: _.get(redisServer, 'port', 6379),
44
44
  db: _.get(redisConfig, 'db', 3),
45
45
  retryStrategy: (times) => {
46
- const delay = Math.min(Math.pow(2, times) * 1000, 300000)
47
- return delay
46
+ const retryArray = [1,2,2,5,5,5,10,10,10,10,15]
47
+ const delay = times < retryArray.length ? retryArray[times] : retryArray.at(retryArray.length)
48
+ return delay*1000
48
49
  },
49
50
  enableReadyCheck: false,
50
51
  maxRetriesPerRequest: null,
@@ -59,15 +60,26 @@ module.exports = function(acapi) {
59
60
 
60
61
  acapi.aclog.serverInfo(redisConf)
61
62
 
63
+ const createRedisClient = ({ config, type }) => {
64
+ const client = new Redis(config)
65
+ client.on('error', (err) => {
66
+ acapi.log.error('BULL/REDIS | Problem | %s | %s', type.padEnd(25), _.get(err, 'message'))
67
+ })
68
+ client.on('ready', () => {
69
+ acapi.log.info('BULL/REDIS | Ready | %s', type)
70
+ })
71
+ return client
72
+ }
73
+
62
74
  const opts = {
63
75
  createClient: (type) => {
64
76
  switch (type) {
65
77
  case 'client':
66
- return new Redis(redisConf)
78
+ return createRedisClient({ config: redisConf, type })
67
79
  case 'subscriber':
68
- return new Redis(redisConf)
80
+ return createRedisClient({ config: redisConf, type })
69
81
  default:
70
- return new Redis(redisConf)
82
+ return createRedisClient({ config: redisConf, type: 'default' })
71
83
  }
72
84
  }
73
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ac-bootstrap-bull",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Bull helper",
5
5
  "repository": "admiralcloud/ac-bootstrap-bull",
6
6
  "author": "Mark Poepping <mark.poepping@admiralcloud.com>",
@@ -9,10 +9,10 @@
9
9
  "ac-redislock": "^2.0.1",
10
10
  "async": "^3.2.4",
11
11
  "bull": "^4.10.2",
12
- "ioredis": "^5.2.4",
12
+ "ioredis": "^5.3.0",
13
13
  "lodash": "^4.17.21"
14
14
  },
15
15
  "devDependencies": {
16
- "eslint": "^8.29.0"
16
+ "eslint": "^8.32.0"
17
17
  }
18
18
  }