Skip to content

Instantly share code, notes, and snippets.

@jthomas
Created December 11, 2017 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jthomas/209955dfafe7f2efaaba614c61290803 to your computer and use it in GitHub Desktop.
Save jthomas/209955dfafe7f2efaaba614c61290803 to your computer and use it in GitHub Desktop.
OpenWhisk Action - Storing State Without a Database
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