Skip to content

Instantly share code, notes, and snippets.

@tripodsan
Created January 27, 2020 01:53
Show Gist options
  • Save tripodsan/9ad3ddf648077f80253e5d264848dfe3 to your computer and use it in GitHub Desktop.
Save tripodsan/9ad3ddf648077f80253e5d264848dfe3 to your computer and use it in GitHub Desktop.
generators and promise all
async function invokePing(ow, cnt) {
log.info(`${cnt}: invoking delayed_ping`);
const result = await ow.actions.invoke({
blocking: true,
name: 'delayed_ping',
result: true,
});
log.info(`${cnt}: done.`);
return result;
}
function *invokePings() {
const ow = openwhisk();
for (let i = 0; i < 4; i++) {
yield invokePing(ow, i);
}
}
async function run(params) {
...
const pings = await Promise.all(Array.from(invokePings()));
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment