openwhisk-wskdeploy icon indicating copy to clipboard operation
openwhisk-wskdeploy copied to clipboard

Add support for Composer

Open pritidesai opened this issue 6 years ago • 7 comments

details to follow ...

pritidesai avatar Mar 15 '18 18:03 pritidesai

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.

epatters avatar Mar 13 '19 22:03 epatters

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

HunderlineK avatar Nov 28 '19 14:11 HunderlineK

@lionelvillard as the composer expert, can you comment?

mrutkows avatar Dec 02 '19 22:12 mrutkows

you want @tardieu, not @lionelvillard

dgrove-oss avatar Dec 02 '19 22:12 dgrove-oss

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')

tardieu avatar Dec 02 '19 23:12 tardieu

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.

tardieu avatar Dec 02 '19 23:12 tardieu

I will add invokeRelative to the composer documentation.

tardieu avatar Dec 02 '19 23:12 tardieu