Chapter 6. Working with Packages

The next feature of OpenWhisk that I’ll discuss is packages. At their heart, packages are merely a way to organize actions. Consider an action that reads tweets from a Twitter account. Now consider another action that searches all of Twitter for a keyword. Finally, imagine an action that can post a tweet for an account. Packages let us do powerful organizational-type tasks with those actions.

First, a package serves an organizational purpose. Any action created is automatically placed in a default package. Actions must also have a unique name. So if you wanted an action named “process,” you couldn’t have more than one. (To be fair, “process” is a pretty poor name by itself.) By using a package, you can place the action inside it, allowing for more than one action with the same name. So for example, an orderSystem package could have an action called “process,” and a userSystem package could have one as well.

Second, packages allow for default parameters that apply to the entire package at once. The Twitter API requires certain authentication values before you can make use of it. If you had multiple actions in a Twitter package, you could supply a default key for all of them at once and not have to worry about setting it on each and every action.

Finally, packages can also be shared. This means that Twitter package described previously could actually be made available to everyone using OpenWhisk. Of course, that then makes it impossible to use a ...

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.