ac-bootstrap-bull 2.1.1 → 2.1.2
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/CHANGELOG.md +15 -0
- package/index.js +17 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
<a name="2.1.2"></a>
|
|
2
|
+
|
|
3
|
+
## [2.1.2](https://github.com/admiralcloud/ac-bootstrap-bull/compare/v2.1.1..v2.1.2) (2024-12-01 17:02:13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fix
|
|
7
|
+
|
|
8
|
+
* **App:** Improved jobId creation | MP | [f6ee6e16539230bf089ee05e337b73d6a0288e0c](https://github.com/admiralcloud/ac-bootstrap-bull/commit/f6ee6e16539230bf089ee05e337b73d6a0288e0c)
|
|
9
|
+
All jobIds should be prefixed with customerId. Job.remove should remove the entry in customer actitivies
|
|
10
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
11
|
+
### Chores
|
|
12
|
+
|
|
13
|
+
* **App:** Updated packages | MP | [dde087d2753e8531dfd6ce3a25b5c664748119ad](https://github.com/admiralcloud/ac-bootstrap-bull/commit/dde087d2753e8531dfd6ce3a25b5c664748119ad)
|
|
14
|
+
Updated packages
|
|
15
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
1
16
|
<a name="2.1.1"></a>
|
|
2
17
|
|
|
3
18
|
## [2.1.1](https://github.com/admiralcloud/ac-bootstrap-bull/compare/v2.1.0..v2.1.1) (2024-10-13 13:37:17)
|
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const _ = require('lodash')
|
|
|
3
3
|
const Redis = require('ioredis')
|
|
4
4
|
const async = require('async')
|
|
5
5
|
const redisLock = require('ac-redislock')
|
|
6
|
+
const { v4: uuidV4 } = require('uuid')
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
module.exports = function(acapi) {
|
|
@@ -158,8 +159,13 @@ module.exports = function(acapi) {
|
|
|
158
159
|
const name = _.get(params, 'name') // named job
|
|
159
160
|
const jobPayload = _.get(params, 'jobPayload')
|
|
160
161
|
const jobOptions = _.get(params, 'jobOptions', {})
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
|
|
163
|
+
// prefix jobIds with customerId, make sure to set a jobId (uuidV4)
|
|
164
|
+
const customerId = _.get(jobPayload, 'customerId')
|
|
165
|
+
if (customerId) {
|
|
166
|
+
const plainJobId = _.get(jobOptions, 'jobId') || _.get(jobPayload, 'jobId') || uuidV4()
|
|
167
|
+
const jobId = plainJobId.startsWith(customerId) ? plainJobId : `${customerId}:::${plainJobId}`
|
|
168
|
+
_.set(jobOptions, 'jobId', jobId)
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
const identifier = _.get(params, 'identifier') // e.g. customerId
|
|
@@ -227,6 +233,15 @@ module.exports = function(acapi) {
|
|
|
227
233
|
removeJob: (done) => {
|
|
228
234
|
job.remove()
|
|
229
235
|
return done()
|
|
236
|
+
},
|
|
237
|
+
cleanUpActivity: async() => {
|
|
238
|
+
if (!acapi.redis.mcCache) return
|
|
239
|
+
const [ customerId, jobIdentifier ] = jobId.split(':::')
|
|
240
|
+
const redisKey = `${acapi.config.environment}:v5:${customerId}:activities`
|
|
241
|
+
const multi = acapi.redis.mcCache.multi()
|
|
242
|
+
multi.hdel(redisKey, jobIdentifier)
|
|
243
|
+
multi.hdel(redisKey, `${jobIdentifier}:progress`)
|
|
244
|
+
await multi.exec()
|
|
230
245
|
}
|
|
231
246
|
}, function allDone(err) {
|
|
232
247
|
if (err) acapi.log.error('%s | %s | %s | %s | Failed %j', functionName, functionIdentifier, queueName, jobId, err)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ac-bootstrap-bull",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Bull helper",
|
|
5
5
|
"repository": "admiralcloud/ac-bootstrap-bull",
|
|
6
6
|
"author": "Mark Poepping <mark.poepping@admiralcloud.com>",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"ac-redislock": "^3.0.0",
|
|
10
10
|
"async": "^3.2.6",
|
|
11
|
-
"bull": "^4.16.
|
|
11
|
+
"bull": "^4.16.4",
|
|
12
12
|
"ioredis": "^5.4.1",
|
|
13
13
|
"lodash": "^4.17.21"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"ac-semantic-release": "^0.4.3",
|
|
17
|
-
"eslint": "^9.
|
|
17
|
+
"eslint": "^9.16.0"
|
|
18
18
|
}
|
|
19
19
|
}
|