@mojaloop/bulk-api-adapter 17.2.2 → 17.2.4
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/.circleci/config.yml +1 -1
- package/.grype.yaml +93 -7
- package/.ncurc.yaml +2 -1
- package/.nvmrc +1 -1
- package/CHANGELOG.md +16 -0
- package/Dockerfile +1 -2
- package/package.json +31 -21
- package/{sbom-v17.2.1.csv → sbom-v17.2.3.csv} +1281 -1282
- package/src/handlers/notification/index.js +28 -1
- package/src/lib/healthCheck/subServiceHealth.js +14 -3
- package/test/unit/health.test.js +4 -4
|
@@ -335,6 +335,32 @@ const isConnected = async () => {
|
|
|
335
335
|
return true
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
+
/**
|
|
339
|
+
* @function isHealthy
|
|
340
|
+
*
|
|
341
|
+
* @description
|
|
342
|
+
* Gets the health for the broker using the consumer's isHealthy() method
|
|
343
|
+
* from central-services-stream which performs comprehensive checks:
|
|
344
|
+
* - isConnected() - basic connection status
|
|
345
|
+
* - isAssigned() - consumer has partition assignments
|
|
346
|
+
* - isPollHealthy() - last poll was within healthCheckPollInterval
|
|
347
|
+
* - getMetadataSync() - all subscribed topics exist in broker metadata
|
|
348
|
+
*
|
|
349
|
+
* @returns {Promise<boolean>} - true if healthy, false otherwise
|
|
350
|
+
*/
|
|
351
|
+
const isHealthy = async () => {
|
|
352
|
+
try {
|
|
353
|
+
const healthy = await notificationConsumer.isHealthy()
|
|
354
|
+
if (!healthy) {
|
|
355
|
+
Logger.isWarnEnabled && Logger.warn('Notification consumer is not healthy')
|
|
356
|
+
}
|
|
357
|
+
return healthy
|
|
358
|
+
} catch (err) {
|
|
359
|
+
Logger.isWarnEnabled && Logger.warn(`isHealthy check failed: ${err.message}`)
|
|
360
|
+
return false
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
338
364
|
/**
|
|
339
365
|
* @function getJWSSigner
|
|
340
366
|
*
|
|
@@ -358,5 +384,6 @@ module.exports = {
|
|
|
358
384
|
startConsumer,
|
|
359
385
|
processMessage,
|
|
360
386
|
consumeMessage,
|
|
361
|
-
isConnected
|
|
387
|
+
isConnected,
|
|
388
|
+
isHealthy
|
|
362
389
|
}
|
|
@@ -32,15 +32,26 @@ const axios = require('axios')
|
|
|
32
32
|
/**
|
|
33
33
|
* @function getSubServiceHealthBroker
|
|
34
34
|
*
|
|
35
|
-
* @description
|
|
35
|
+
* @description
|
|
36
|
+
* Gets the health for the broker using the consumer's isHealthy() method
|
|
37
|
+
* from central-services-stream which performs comprehensive checks:
|
|
38
|
+
* - isConnected() - basic connection status
|
|
39
|
+
* - isAssigned() - consumer has partition assignments
|
|
40
|
+
* - isPollHealthy() - last poll was within healthCheckPollInterval
|
|
41
|
+
* - getMetadataSync() - all subscribed topics exist in broker metadata
|
|
42
|
+
*
|
|
36
43
|
* @returns Promise<SubServiceHealth> The SubService health object for the broker
|
|
37
44
|
*/
|
|
38
45
|
const getSubServiceHealthBroker = async () => {
|
|
39
46
|
let status = statusEnum.OK
|
|
40
47
|
try {
|
|
41
|
-
await Notification.
|
|
48
|
+
const isHealthy = await Notification.isHealthy()
|
|
49
|
+
if (!isHealthy) {
|
|
50
|
+
Logger.isDebugEnabled && Logger.debug('getSubServiceHealthBroker: consumer is not healthy')
|
|
51
|
+
status = statusEnum.DOWN
|
|
52
|
+
}
|
|
42
53
|
} catch (err) {
|
|
43
|
-
Logger.debug(`getSubServiceHealthBroker failed with error: ${err.message}.`)
|
|
54
|
+
Logger.isDebugEnabled && Logger.debug(`getSubServiceHealthBroker failed with error: ${err.message}.`)
|
|
44
55
|
status = statusEnum.DOWN
|
|
45
56
|
}
|
|
46
57
|
|
package/test/unit/health.test.js
CHANGED
|
@@ -15,7 +15,7 @@ Test('health handler', (handlerTest) => {
|
|
|
15
15
|
|
|
16
16
|
handlerTest.beforeEach(t => {
|
|
17
17
|
sandbox = Sinon.createSandbox()
|
|
18
|
-
sandbox.stub(Notification, '
|
|
18
|
+
sandbox.stub(Notification, 'isHealthy')
|
|
19
19
|
sandbox.stub(axios, 'get')
|
|
20
20
|
healthHandler = proxyquire('../../src/api/handlers/health', {})
|
|
21
21
|
t.end()
|
|
@@ -29,7 +29,7 @@ Test('health handler', (handlerTest) => {
|
|
|
29
29
|
|
|
30
30
|
handlerTest.test('/health should', healthTest => {
|
|
31
31
|
healthTest.test('return the correct response when the health check is up', async test => {
|
|
32
|
-
Notification.
|
|
32
|
+
Notification.isHealthy.resolves(true)
|
|
33
33
|
axios.get.resolves({ data: { status: 'OK' } })
|
|
34
34
|
const expectedResponseCode = 200
|
|
35
35
|
const {
|
|
@@ -41,7 +41,7 @@ Test('health handler', (handlerTest) => {
|
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
healthTest.test('return the correct response when the health check is up in API mode only (Config.HANDLERS_DISABLED=true)', async test => {
|
|
44
|
-
Notification.
|
|
44
|
+
Notification.isHealthy.resolves(true)
|
|
45
45
|
|
|
46
46
|
Config.HANDLERS_DISABLED = true
|
|
47
47
|
healthHandler = proxyquire('../../src/api/handlers/health', {})
|
|
@@ -57,7 +57,7 @@ Test('health handler', (handlerTest) => {
|
|
|
57
57
|
|
|
58
58
|
healthTest.test('return the correct response when the health check is down', async test => {
|
|
59
59
|
healthHandler = proxyquire('../../src/api/handlers/health', {})
|
|
60
|
-
Notification.
|
|
60
|
+
Notification.isHealthy.resolves(false)
|
|
61
61
|
axios.get.resolves({ data: { status: 'OK' } })
|
|
62
62
|
const expectedResponseCode = 502
|
|
63
63
|
const {
|