Skip to content

Commit

Permalink
Merge pull request #1890 from Accenture/bug/1889-throttle-mcdev-refre…
Browse files Browse the repository at this point in the history
…sh-to-avoid-timeouts

bug/1889 throttle refresh to 10 concurrent triggeredSends; add icons for pause/publish/start
  • Loading branch information
JoernBerkefeld authored Nov 21, 2024
2 parents c725d7b + 6153139 commit f6ad6f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/TriggeredSend.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions lib/metadataTypes/TriggeredSend.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import asset from './Asset.js';
import folder from './Folder.js';
import list from './List.js';
import ReplaceCbReference from '../util/replaceContentBlockReference.js';
import pLimit from 'p-limit';

/**
* @typedef {import('../../types/mcdev.d.js').BuObject} BuObject
Expand Down Expand Up @@ -312,13 +313,20 @@ class TriggeredSend extends MetadataType {
checkKey = false;
}
// then executes pause, publish, start on them.
const refreshList = [];
Util.logger.info(`Refreshing ${keyArr.length} ${this.definition.typeName}...`);
Util.logger.debug(`Refreshing keys: ${keyArr.join(', ')}`);
for (const key of keyArr) {
refreshList.push(this._refreshItem(key, checkKey));
}
const successCounter = (await Promise.all(refreshList)).filter(Boolean).length;
let successCounter = 0;
const rateLimit = pLimit(10);
await Promise.all(
keyArr.map((key) =>
rateLimit(async () => {
const result = await this._refreshItem(key, checkKey);
if (result) {
successCounter++;
}
})
)
);
Util.logger.info(`Refreshed ${successCounter} of ${keyArr.length}`);
console.timeEnd('Time'); // eslint-disable-line no-console
}
Expand Down Expand Up @@ -452,7 +460,7 @@ class TriggeredSend extends MetadataType {
throw new Error(test.Results[0].StatusMessage);
}
delete item.TriggeredSendStatus;
Util.logger.info(` - paused ${this.definition.typeName}: ${key}`);
Util.logger.info(` - 🛑 paused ${this.definition.typeName}: ${key}`);
} catch (ex) {
const errorMsg = super.getSOAPErrorMsg(ex);

Expand All @@ -470,7 +478,7 @@ class TriggeredSend extends MetadataType {
throw new Error(test.Results[0].StatusMessage);
}
delete item.RefreshContent;
Util.logger.info(` - published ${this.definition.typeName}: ${key}`);
Util.logger.info(` - 🔃 published ${this.definition.typeName}: ${key}`);
} catch (ex) {
const errorMsg = super.getSOAPErrorMsg(ex);
Util.logger.error(
Expand All @@ -487,7 +495,7 @@ class TriggeredSend extends MetadataType {
throw new Error(test.Results[0].StatusMessage);
}
delete item.RefreshContent;
Util.logger.info(` - started ${this.definition.typeName}: ${key}`);
Util.logger.info(` - started ${this.definition.typeName}: ${key}`);
} catch (ex) {
const errorMsg = super.getSOAPErrorMsg(ex);
Util.logger.error(
Expand Down

0 comments on commit f6ad6f1

Please sign in to comment.