account-lookup-service 17.11.0-snapshot.0 → 17.11.1-snapshot.0

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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [17.11.0](https://github.com/mojaloop/account-lookup-service/compare/v17.10.3...v17.11.0) (2025-07-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * **csi-1604:** used ha timeout design with redlock impl ([#556](https://github.com/mojaloop/account-lookup-service/issues/556)) ([17a2477](https://github.com/mojaloop/account-lookup-service/commit/17a24779fb39b09ee535cd908f4f30ab45e57a8e))
11
+
5
12
  ### [17.10.3](https://github.com/mojaloop/account-lookup-service/compare/v17.10.2...v17.10.3) (2025-06-24)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "account-lookup-service",
3
3
  "description": "Account Lookup Service is used to validate Party and Participant lookups.",
4
- "version": "17.11.0-snapshot.0",
4
+ "version": "17.11.1-snapshot.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
@@ -95,9 +95,9 @@
95
95
  "@mojaloop/central-services-health": "15.1.0",
96
96
  "@mojaloop/central-services-logger": "11.9.0",
97
97
  "@mojaloop/central-services-metrics": "12.6.0",
98
- "@mojaloop/central-services-shared": "18.29.0-snapshot.0",
99
- "@mojaloop/central-services-stream": "11.8.0",
100
- "@mojaloop/database-lib": "11.2.0",
98
+ "@mojaloop/central-services-shared": "18.29.0",
99
+ "@mojaloop/central-services-stream": "^11.8.0",
100
+ "@mojaloop/database-lib": "11.2.1",
101
101
  "@mojaloop/event-sdk": "14.6.1",
102
102
  "@mojaloop/inter-scheme-proxy-cache-lib": "2.6.0",
103
103
  "@mojaloop/ml-schema-transformer-lib": "2.7.1",
@@ -166,7 +166,7 @@
166
166
  "axios": "1.10.0",
167
167
  "axios-retry": "^4.5.0",
168
168
  "docdash": "2.0.2",
169
- "dotenv": "^17.0.1",
169
+ "dotenv": "^17.1.0",
170
170
  "get-port": "5.1.1",
171
171
  "ioredis-mock": "^8.9.0",
172
172
  "jest": "29.7.0",
package/src/api/health.js CHANGED
@@ -27,7 +27,7 @@
27
27
  'use strict'
28
28
 
29
29
  const HealthCheck = require('@mojaloop/central-services-shared').HealthCheck.HealthCheck
30
- const { getSubServiceHealthDatastore, getProxyCacheHealth } = require('../lib/healthCheck/subServiceHealth')
30
+ const { getSubServiceHealthDatastore, getProxyCacheHealth, getSubServiceHealthBroker } = require('../lib/healthCheck/subServiceHealth')
31
31
  const packageJson = require('../../package.json')
32
32
  const Config = require('../lib/config')
33
33
 
@@ -36,7 +36,8 @@ const getSubServices = (appConfig, isAdmin) => {
36
36
  return [getSubServiceHealthDatastore]
37
37
  }
38
38
 
39
- const subServices = [getSubServiceHealthDatastore]
39
+ const subServices = [getSubServiceHealthDatastore, getSubServiceHealthBroker]
40
+
40
41
  if (appConfig.PROXY_CACHE_CONFIG.enabled) {
41
42
  subServices.push(getProxyCacheHealth)
42
43
  }
@@ -44,17 +44,19 @@ let distLock
44
44
  const timeout = async (options) => {
45
45
  if (isRunning) return
46
46
  const { logger } = options
47
+ let isAcquired = false
47
48
 
48
49
  try {
49
50
  isRunning = true
50
- if (!await distLock?.acquireLock()) return
51
+ isAcquired = await distLock?.acquireLock()
52
+ if (!isAcquired) return
51
53
  await TimeoutService.timeoutInterschemePartiesLookups(options)
52
54
  await TimeoutService.timeoutProxyGetPartiesLookups(options)
53
55
  logger.verbose('ALS timeout handler is done')
54
56
  } catch (err) {
55
57
  logger.error('error in timeout: ', err)
56
58
  } finally {
57
- await distLock?.releaseLock()
59
+ if (isAcquired) await distLock.releaseLock()
58
60
  isRunning = false
59
61
  }
60
62
  }
@@ -88,7 +90,7 @@ const register = async (options) => {
88
90
  const stop = async () => {
89
91
  if (isRegistered) {
90
92
  await timeoutJob.stop()
91
- // await distLock?.releaseLock()
93
+ await distLock?.releaseLock()
92
94
  isRegistered = false
93
95
  }
94
96
  }
@@ -20,14 +20,14 @@
20
20
 
21
21
  const { HealthCheck } = require('@mojaloop/central-services-shared').HealthCheck
22
22
  const { defaultHealthHandler } = require('@mojaloop/central-services-health')
23
- const { getProxyCacheHealth } = require('../../../lib/healthCheck/subServiceHealth')
23
+ const { getProxyCacheHealth, getSubServiceHealthBroker } = require('../../../lib/healthCheck/subServiceHealth')
24
24
  const packageJson = require('../../../../package.json')
25
25
 
26
26
  let healthCheck
27
27
 
28
28
  const createHealthCheck = ({ proxyCache }) => {
29
29
  return new HealthCheck(packageJson, [
30
- () => getProxyCacheHealth(proxyCache)
30
+ () => getProxyCacheHealth(proxyCache), () => getSubServiceHealthBroker()
31
31
  ])
32
32
  }
33
33
 
package/src/lib/config.js CHANGED
@@ -162,7 +162,6 @@ const config = {
162
162
  HANDLERS_TIMEOUT_TIMEXP: RC.HANDLERS.TIMEOUT.TIMEXP,
163
163
  HANDLERS_TIMEOUT_TIMEZONE: RC.HANDLERS.TIMEOUT.TIMEZONE,
164
164
  HANDLERS_TIMEOUT_BATCH_SIZE: RC.HANDLERS.TIMEOUT.BATCH_SIZE,
165
- HANDLERS_TIMEOUT_DIST_LOCK_ENABLED: RC.HANDLERS.TIMEOUT?.DIST_LOCK?.enabled,
166
165
  ERROR_HANDLING: RC.ERROR_HANDLING,
167
166
  SWITCH_ENDPOINT: RC.SWITCH_ENDPOINT,
168
167
  INSTRUMENTATION_METRICS_DISABLED: RC.INSTRUMENTATION.METRICS.DISABLED,
@@ -26,6 +26,7 @@
26
26
  const { statusEnum, serviceName } = require('@mojaloop/central-services-shared').HealthCheck.HealthCheckEnums
27
27
  const { logger } = require('../../lib')
28
28
  const MigrationLockModel = require('../../models/misc/migrationLock')
29
+ const Producer = require('@mojaloop/central-services-stream').Util.Producer
29
30
 
30
31
  /**
31
32
  * @function getSubServiceHealthDatastore
@@ -54,6 +55,28 @@ const getSubServiceHealthDatastore = async () => {
54
55
  }
55
56
  }
56
57
 
58
+ /**
59
+ * @function getSubServiceHealthBroker
60
+ *
61
+ * @description Gets the health for the Notification broker
62
+ * @returns Promise<object> The SubService health object for the broker
63
+ */
64
+ const getSubServiceHealthBroker = async () => {
65
+ let status = statusEnum.OK
66
+ try {
67
+ await Producer.allConnected()
68
+ status = statusEnum.OK
69
+ } catch (err) {
70
+ logger.isDebugEnabled && logger.debug(`getSubServiceHealthBroker failed with error: ${err.message}.`)
71
+ status = statusEnum.DOWN
72
+ }
73
+
74
+ return {
75
+ name: serviceName.broker,
76
+ status
77
+ }
78
+ }
79
+
57
80
  /**
58
81
  * @function getProxyCacheHealth
59
82
  *
@@ -79,5 +102,6 @@ const getProxyCacheHealth = async (proxyCache) => {
79
102
 
80
103
  module.exports = {
81
104
  getSubServiceHealthDatastore,
82
- getProxyCacheHealth
105
+ getProxyCacheHealth,
106
+ getSubServiceHealthBroker
83
107
  }
@@ -86,7 +86,7 @@ describe('/health', () => {
86
86
  expect(response.statusCode).toBe(200)
87
87
  const payload = JSON.parse(response.payload)
88
88
  expect(payload.status).toBe('OK')
89
- expect(payload.services.length).toBe(1)
89
+ expect(payload.services.length).toBe(2)
90
90
  expect(payload.services[0].name).toBe('datastore')
91
91
  })
92
92
 
@@ -108,7 +108,7 @@ describe('/health', () => {
108
108
  expect(response.statusCode).toBe(503)
109
109
  const payload = JSON.parse(response.payload)
110
110
  expect(payload.status).toBe('DOWN')
111
- expect(payload.services.length).toBe(1)
111
+ expect(payload.services.length).toBe(2)
112
112
  expect(payload.services[0].name).toBe('datastore')
113
113
  })
114
114
 
@@ -135,8 +135,8 @@ describe('/health', () => {
135
135
  // Assert
136
136
  const payload = JSON.parse(response.payload)
137
137
  expect(response.statusCode).toBe(200)
138
- expect(payload.services.length).toBe(2)
139
- expect(payload.services[1].name).toBe('proxyCache')
138
+ expect(payload.services.length).toBe(3)
139
+ expect(payload.services[2].name).toBe('proxyCache')
140
140
  } finally {
141
141
  serverWithProxy && await serverWithProxy.stop()
142
142
  }
@@ -84,7 +84,7 @@ describe('TimeoutHandler', () => {
84
84
  await TimeoutHandler.stop()
85
85
  })
86
86
 
87
- it('should execute timout service', async () => {
87
+ it('should execute timeout service', async () => {
88
88
  await TimeoutHandler.register(mockOptions)
89
89
  jest.spyOn(TimeoutService, 'timeoutInterschemePartiesLookups').mockResolvedValue()
90
90
  await TimeoutHandler.timeout(mockOptions)
@@ -93,7 +93,6 @@ describe('TimeoutHandler', () => {
93
93
 
94
94
  it('should not run if isRunning is true (distLock disabled)', async () => {
95
95
  await TimeoutHandler.register(mockOptions)
96
- Config.HANDLERS_TIMEOUT_DIST_LOCK_ENABLED = false
97
96
  jest.spyOn(TimeoutService, 'timeoutInterschemePartiesLookups').mockImplementation(async () => {
98
97
  await wait(1000)
99
98
  })
@@ -124,7 +123,7 @@ describe('TimeoutHandler', () => {
124
123
  await TimeoutHandler.timeout(mockOptions)
125
124
 
126
125
  expect(mockDistLock.acquire).toHaveBeenCalledTimes(1)
127
- expect(mockDistLock.release).toHaveBeenCalled() // todo: think if we need .release() to have been called
126
+ expect(mockDistLock.release).not.toHaveBeenCalled()
128
127
  expect(TimeoutService.timeoutProxyGetPartiesLookups).not.toHaveBeenCalled()
129
128
  })
130
129
  })