Chapter 5. Building Sequences
You’ve just learned how to build actions that can be deployed as serverless functions with Apache OpenWhisk. One of the more powerful ways you can use an action is as part of a sequence. In essense, a sequence is simply an action that consists of other actions. Let’s consider a simple example.
Imagine an action that simply takes a number and adds one to it. Let’s call it the Incrementor.
Now imagine another action that takes a number and doubles it. We’ll call that the Doubler.
If you wanted to both increment and double a number, you could simply pass your input to Incrementor, get the result, and then pass that result to Doubler. That would require two network calls (see Figure 5-1) but probably wouldn’t be terribly slow.
But OpenWhisk provides a better way. By combining both actions into a sequence (as shown in Figure 5-2), the person calling the serverless function can work with both actions at once. To the client, it’s simply another action, but behind the scenes, multiple actions are working together to create a result.
When we first introduced actions, we mentioned that you should make them small and focus them on one thing only. This becomes incredibly important when ...
Get Developing Serverless Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.