Parallelize pull of Locations
MODIFY
src/client/ocpi/EmspOCPIClient.ts
src/client/ocpi/EmspOCPIClient.ts
@@ -164,7 +164,9 @@ export default class EmspOCPIClient extends OCPIClient {
Authorization: `Token ${this.ocpiEndpoint.token}`
},
});
- for (const location of response.data.data as OCPILocation[]) {
+ const locations = response.data.data as OCPILocation[];
+ if (!Utils.isEmptyArray(locations)) {
+ await Promise.map(locations, async (location: OCPILocation) => {
try {
await this.processLocation(location, company, sites.result);
result.success++;
@@ -174,6 +176,8 @@ export default class EmspOCPIClient extends OCPIClient {
`Failed to update Location '${location.name}': ${error.message}`
);
}
+ },
+ { concurrency: Constants.OCPI_MAX_PARALLEL_REQUESTS });
}
const nextUrl = OCPIUtils.getNextUrl(response.headers.link);
if (nextUrl && nextUrl.length > 0 && nextUrl !== locationsUrl) {

Parallelize pull of Locations