account-lookup-service 17.7.0-snapshot.2 → 17.7.0-snapshot.5
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/package.json +2 -2
- package/src/domain/parties/services/BasePartiesService.js +3 -3
- package/src/domain/parties/services/GetPartiesService.js +3 -4
- package/src/domain/parties/services/PutPartiesErrorService.js +1 -1
- package/src/domain/parties/services/PutPartiesService.js +1 -1
- package/src/domain/timeout/index.js +11 -8
- package/test/unit/domain/parties/services/BasePartiesService.test.js +12 -0
- package/test/unit/domain/parties/services/GetPartiesService.test.js +3 -1
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.7.0-snapshot.
|
4
|
+
"version": "17.7.0-snapshot.5",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "ModusBox",
|
7
7
|
"contributors": [
|
@@ -92,7 +92,7 @@
|
|
92
92
|
"@hapi/vision": "7.0.3",
|
93
93
|
"@mojaloop/central-services-error-handling": "13.0.7",
|
94
94
|
"@mojaloop/central-services-health": "15.0.4",
|
95
|
-
"@mojaloop/central-services-logger": "11.
|
95
|
+
"@mojaloop/central-services-logger": "11.8.0",
|
96
96
|
"@mojaloop/central-services-metrics": "12.5.0",
|
97
97
|
"@mojaloop/central-services-shared": "18.23.1",
|
98
98
|
"@mojaloop/central-services-stream": "11.5.2",
|
@@ -142,9 +142,9 @@ class BasePartiesService {
|
|
142
142
|
return this.deps.oracle.oracleRequest(headers, RestMethods.DELETE, params, null, null, this.deps.cache)
|
143
143
|
}
|
144
144
|
|
145
|
-
async
|
146
|
-
const isRemoved = await this.deps.proxyCache.removeProxyGetPartiesTimeout(alsReq)
|
147
|
-
this.log.debug('
|
145
|
+
async removeProxyGetPartiesTimeoutCache (alsReq) {
|
146
|
+
const isRemoved = await this.deps.proxyCache.removeProxyGetPartiesTimeout(alsReq, this.state.proxy)
|
147
|
+
this.log.debug('removeProxyGetPartiesTimeoutCache is done', { isRemoved, alsReq })
|
148
148
|
return isRemoved
|
149
149
|
}
|
150
150
|
|
@@ -282,13 +282,12 @@ class GetPartiesService extends BasePartiesService {
|
|
282
282
|
async #setProxyGetPartiesTimeout (sendTo) {
|
283
283
|
const isLocalSource = this.isLocalSource()
|
284
284
|
const isSentToProxy = this.state.destination !== sendTo
|
285
|
-
this.log.verbose('isLocalSource and isSentToProxy: ', { isLocalSource, isSentToProxy })
|
285
|
+
this.log.verbose('isLocalSource and isSentToProxy: ', { isLocalSource, isSentToProxy, sendTo })
|
286
286
|
|
287
287
|
if (isSentToProxy && isLocalSource) {
|
288
288
|
this.stepInProgress('#setProxyGetPartiesTimeout')
|
289
|
-
const
|
290
|
-
const
|
291
|
-
const isSet = await this.deps.proxyCache.setProxyGetPartiesTimeout(alsReq, proxy)
|
289
|
+
const alsReq = this.deps.partiesUtils.alsRequestDto(this.state.source, this.inputs.params)
|
290
|
+
const isSet = await this.deps.proxyCache.setProxyGetPartiesTimeout(alsReq, sendTo)
|
292
291
|
this.log.info('#setProxyGetPartiesTimeout is done', { isSet })
|
293
292
|
return isSet
|
294
293
|
}
|
@@ -39,7 +39,7 @@ class PutPartiesErrorService extends BasePartiesService {
|
|
39
39
|
// not initial inter-scheme discovery case. Cleanup oracle and trigger inter-scheme discovery
|
40
40
|
this.log.warn('Need to cleanup oracle and trigger new inter-scheme discovery flow')
|
41
41
|
await this.cleanupOracle()
|
42
|
-
await this.
|
42
|
+
await this.removeProxyGetPartiesTimeoutCache(alsReq)
|
43
43
|
return true // need to trigger inter-scheme discovery
|
44
44
|
}
|
45
45
|
|
@@ -74,7 +74,7 @@ class PutPartiesService extends BasePartiesService {
|
|
74
74
|
const isExists = await this.deps.proxyCache.receivedSuccessResponse(alsReq)
|
75
75
|
if (!isExists) {
|
76
76
|
this.log.verbose('NOT inter-scheme receivedSuccessResponse case')
|
77
|
-
await this.
|
77
|
+
await this.removeProxyGetPartiesTimeoutCache(alsReq)
|
78
78
|
return
|
79
79
|
}
|
80
80
|
|
@@ -44,15 +44,17 @@ const Metrics = require('@mojaloop/central-services-metrics')
|
|
44
44
|
|
45
45
|
const Participant = require('../../models/participantEndpoint/facade')
|
46
46
|
const { ERROR_MESSAGES } = require('../../constants')
|
47
|
-
const { timeoutCallbackDto } = require('./dto')
|
48
47
|
const { logger } = require('../../lib')
|
49
|
-
const
|
48
|
+
const { countFspiopError } = require('../../lib/util')
|
49
|
+
const { timeoutCallbackDto } = require('./dto')
|
50
50
|
|
51
51
|
const timeoutInterschemePartiesLookups = async ({ proxyCache, batchSize }) => {
|
52
|
+
logger.info('timeoutInterschemePartiesLookups start...', { batchSize })
|
52
53
|
return proxyCache.processExpiredAlsKeys(sendTimeoutCallback, batchSize)
|
53
54
|
}
|
54
55
|
|
55
56
|
const timeoutProxyGetPartiesLookups = async ({ proxyCache, batchSize }) => {
|
57
|
+
logger.info('timeoutProxyGetPartiesLookups start...', { batchSize })
|
56
58
|
return proxyCache.processExpiredProxyGetPartiesKeys(sendTimeoutCallback, batchSize)
|
57
59
|
}
|
58
60
|
|
@@ -65,31 +67,32 @@ const sendTimeoutCallback = async (cacheKey) => {
|
|
65
67
|
let step
|
66
68
|
const [destination, partyType, partyId] = parseCacheKey(cacheKey)
|
67
69
|
const { errorInformation, params, headers, endpointType, span } = await timeoutCallbackDto({ destination, partyId, partyType })
|
68
|
-
logger.
|
70
|
+
const log = logger.child({ destination, partyId })
|
71
|
+
log.verbose('sendTimeoutCallback details:', { errorInformation, cacheKey, partyType })
|
69
72
|
|
70
73
|
try {
|
71
74
|
step = 'validateParticipant-1'
|
72
|
-
await validateParticipant(destination)
|
75
|
+
await validateParticipant(destination, log)
|
73
76
|
await span.audit({ headers, errorInformation }, AuditEventAction.start)
|
74
77
|
step = 'sendErrorToParticipant-2'
|
75
78
|
await Participant.sendErrorToParticipant(destination, endpointType, errorInformation, headers, params, undefined, span)
|
76
79
|
histTimerEnd({ success: true })
|
77
80
|
} catch (err) {
|
78
|
-
|
81
|
+
log.warn('error in sendTimeoutCallback: ', err)
|
79
82
|
histTimerEnd({ success: false })
|
80
83
|
const fspiopError = reformatFSPIOPError(err)
|
81
|
-
|
84
|
+
countFspiopError(fspiopError, { operation: 'sendTimeoutCallback', step })
|
82
85
|
|
83
86
|
await finishSpan(span, fspiopError)
|
84
87
|
throw fspiopError
|
85
88
|
}
|
86
89
|
}
|
87
90
|
|
88
|
-
const validateParticipant = async (fspId) => {
|
91
|
+
const validateParticipant = async (fspId, log) => {
|
89
92
|
const participant = await Participant.validateParticipant(fspId)
|
90
93
|
if (!participant) {
|
91
94
|
const errMessage = ERROR_MESSAGES.partyDestinationFspNotFound
|
92
|
-
|
95
|
+
log.error(`error in validateParticipant: ${errMessage}`)
|
93
96
|
throw createFSPIOPError(FSPIOPErrorCodes.DESTINATION_FSP_ERROR, errMessage)
|
94
97
|
}
|
95
98
|
return participant
|
@@ -56,4 +56,16 @@ describe('BasePartiesService Tests -->', () => {
|
|
56
56
|
expect(payload.Rpt.OrgnlId).toBe(`${params.Type}/${params.ID}`)
|
57
57
|
expect(payload.Assgnmt.Assgnr.Agt.FinInstnId.Othr.Id).toBe(source)
|
58
58
|
})
|
59
|
+
|
60
|
+
test('should remove proxy getParties timeout cache key', async () => {
|
61
|
+
const deps = createMockDeps()
|
62
|
+
const proxy = 'proxyAB'
|
63
|
+
const headers = fixtures.partiesCallHeadersDto({ proxy })
|
64
|
+
const params = fixtures.partiesParamsDto()
|
65
|
+
const alsReq = {}
|
66
|
+
const service = new BasePartiesService(deps, { headers, params })
|
67
|
+
|
68
|
+
await service.removeProxyGetPartiesTimeoutCache(alsReq)
|
69
|
+
expect(deps.proxyCache.removeProxyGetPartiesTimeout).toHaveBeenCalledWith(alsReq, proxy)
|
70
|
+
})
|
59
71
|
})
|
@@ -156,8 +156,9 @@ describe('GetPartiesService Tests -->', () => {
|
|
156
156
|
participantMock.validateParticipant = jest.fn()
|
157
157
|
.mockResolvedValueOnce({}) // source
|
158
158
|
.mockResolvedValueOnce(null) // destination
|
159
|
+
const proxyId = 'proxy-destination'
|
159
160
|
const proxyCache = createProxyCacheMock({
|
160
|
-
lookupProxyByDfspId: jest.fn().mockResolvedValueOnce(
|
161
|
+
lookupProxyByDfspId: jest.fn().mockResolvedValueOnce(proxyId)
|
161
162
|
})
|
162
163
|
const deps = createMockDeps({ proxyCache })
|
163
164
|
const headers = fixtures.partiesCallHeadersDto()
|
@@ -166,6 +167,7 @@ describe('GetPartiesService Tests -->', () => {
|
|
166
167
|
|
167
168
|
await service.handleRequest()
|
168
169
|
expect(proxyCache.setProxyGetPartiesTimeout).toHaveBeenCalledTimes(1)
|
170
|
+
expect(proxyCache.setProxyGetPartiesTimeout.mock.lastCall[1]).toBe(proxyId)
|
169
171
|
expect(participantMock.sendRequest).toHaveBeenCalledTimes(1)
|
170
172
|
})
|
171
173
|
|