This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const compensatingActions = []; | |
try { | |
await lockResource(); | |
compensatingActions.push(unlockResource); | |
const receipt = await processPayment(); | |
compensatingActions.push(() => cancelPayment(receipt)); | |
await addBillingItem(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Saga() | |
.do(lockResource) | |
.withCompensatingAction(unlockResource) | |
.then(processPayment) | |
.withCompensatingAction(cancelPayment) | |
.then(addBillingItem); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scenarioRunner.js | |
async function scenarioRunner(scenarioIds, runScenario) { | |
try { | |
await Promise.all(scenarioIds.map(runScenario)); | |
} catch (error) { | |
console.log("A scenario failed", error); | |
} | |
} | |
// scenarioRunner.spec.js |
OlderNewer