Created
January 27, 2020 01:53
-
-
Save tripodsan/9ad3ddf648077f80253e5d264848dfe3 to your computer and use it in GitHub Desktop.
generators and promise all
This file contains 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
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