koelschkellerkind
koelschkellerkind

Reputation: 1

Openwhisk composer: How to set parameters for Redis instance to use parallel composition

I'm running OpenWhisk on Kubernetes and my Redis instance is running in a pod. I want to use the parallel combinator but I'll always get the following error Parallel combinator requires a properly configured redis instance when I execute serverless invoke -f conductor.

For me it's not really clear where I have to define the access to my Redis instance. Currently I've defined it in the input parameter object to the parallel composition, but I'm not sure if that's right. Can you please help? Thanks in advance!

Compose file "composition.js":

'use strict';

const composer = require('openwhisk-composer');

module.exports = composer.sequence(
    composer.function(() => ({
        "$composer": {
            "openwhisk": {
                "ignore_certs": true
            },
            "redis": {
                "uri": "redis://redis.default.svc.cluster.local:6379"
            }
        }
    })),
    composer.parallel(
        composer.action('fanOut-dev-alpha'), 
        composer.action('fanOut-dev-alpha')
    )
);

Function file "handler.js":

'use strict';

function alpha(params) {
  return new Promise((resolve) => {setTimeout(resolve, 1000)})
}

module.exports.alpha = alpha;

Serverless file "composition.js":

service: fanOut

provider:
  name: openwhisk
  ignore_certs: true

functions:
  conductor:
    handler: composition.conductor.main
    annotations:
      conductor: true
  alpha:
    handler: handler.alpha

plugins:
  - serverless-openwhisk

Upvotes: 0

Views: 191

Answers (1)

King.Zevin
King.Zevin

Reputation: 71

The json parameter including "$composer" token should be passed as the input parameter of the invocation of the outmost composition action. In your case, it should be similar to this:

# your input json should be like:
$ cat input.json
> {
  "$composer": {
      "openwhisk": {
          "ignore_certs": true
      },
      "redis": {
          "uri": "redis://redis.default.svc.cluster.local:6379"
      }
  },
  "key":"value"
}
# then you can invoke it with this 
$ serverless invoke -f conductor -p input.json
# or if you're using wsk-cli
$ wsk -i action invoke <your composition action> -P input.json

Upvotes: 1

Related Questions