Created
December 11, 2017 14:11
-
-
Save jthomas/209955dfafe7f2efaaba614c61290803 to your computer and use it in GitHub Desktop.
OpenWhisk Action - Storing State Without a Database
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
const openwhisk = require('openwhisk'); | |
const main = async evt => { | |
const count = (evt.count || 0) + 1 | |
// use client library to retrieve current function configuration | |
const ow = openwhisk() | |
const action = await ow.actions.get('counter') | |
// update default parameters with new value | |
action.parameters = [{key: 'count', value: count}] | |
await ow.actions.update({name: 'counter', action}) | |
const message = `Function has been invoked ${count} times.` | |
return { message } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment