openwhisk-wskdeploy
openwhisk-wskdeploy copied to clipboard
Add support for Composer
details to follow ...
In view of #834 and #978, can you please clarify the status of Composer support? Can I already use composer with wskdeploy by first compiling using the composer
command, then handing off the resulting JSON file to wskdeploy as a conductor action? Thanks.
I am following the same approach as @epatters
"scripts": {
"build": "mkdir ./dist && compose index.js --js > ./dist/bundle.js",
},
It just seems when referencing an action inside a compose we need to prefix it with the package name as well? i.e. composer.retry(3, 'package-name/action-name')
instead of composer.retry(3,
action-name)
, even if they are defined in the same package
@lionelvillard as the composer expert, can you comment?
you want @tardieu, not @lionelvillard
The action name may specify the namespace and/or package containing the action following the usual OpenWhisk grammar. If no namespace is specified, the default namespace is assumed. If no package is specified, the default package is assumed.
https://github.com/apache/openwhisk-composer/blob/master/docs/COMBINATORS.md#action
It is possible however to invoke an action from the same package without specifying the package name in advance by replacing composer.action
with something like invokeRelative
:
const composer = require('openwhisk-composer')
function invokeRelative (name) {
return composer.let(
{ name },
params => ({ type: 'action', params, name: process.env.__OW_ACTION_NAME.split('/').slice(0, -1).concat(name).join('/') }),
composer.dynamic())
}
module.exports = invokeRelative('action-name')
I believe conductor actions like sequence actions interpret unqualified action names in the same way. Unqualified names are assumed to refer to the default package. Composer is no different. But invokeRelative
can work around that.
I will add invokeRelative
to the composer documentation.