Developing software in the Real World

Invoking many OpenWhisk actions from another one

I have a project where I need to store a number of items into a data store. I have an OpenWhisk action that stores the items so I wrote an action that takes advantage of the OpenWhisk JS client library to do invoke my store action once for each item in an array that this action receives.

This is the JavaScript code that I used:

This is a NodeJS v8 action (--kind nodejs:8 when creating via wsk) and does two things: create an actions array of all the invoke() calls for the items via the magic of map() and then it uses Promise.all() to execute them.

The actions are invoked in non-blocking mode which means that this action doesn’t need to wait for them to finish and so it returns quickly and then OpenWhisk goes about its business storing my items to the database.

Once in the database, I can use a trigger to invoke another action to do something with the data safe in the knowledge that it’s been saved securely.

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *