0

按照http://heidloff.net/article/how-to-trigger-openwhisk-cloudant中概述的步骤,触发的操作不会接收 JSON 文档作为参数,即使触发器定义包括includeDocs true.

细节:

定义一个displayEvent.js简单地返回参数的动作 ( ):

function main(params) {
  return {payload:  params};
}

创建动作:

$ wsk action update displayEvent displayEvent.js
ok: updated action displayEvent

绑定 Cloudant 包:

$ wsk package bind /whisk.system/cloudant srcCloudant --param bluemixServiceName cloudant_for_openwhisk --param dbname src --param host *** --param overwrite false --param username *** --param password ***

为 Cloudant 更改提要创建触发器:

$ wsk trigger create newTrackingEvent --feed /ptitzler_org_dev/srcCloudant/changes --param includeDocs true 
ok: invoked /...

(我也试过参数include_docs,但结果是一样的。)

活动日志条目:

"2017-01-25T16:12:34.711142625Z stdout: cloudant trigger feed:  { bluemixServiceName: 'cloudant_for_openwhisk',",
"2017-01-25T16:12:34.711173464Z stdout: authKey: '***',",
"2017-01-25T16:12:34.711184757Z stdout: username: '***',",
"2017-01-25T16:12:34.711194489Z stdout: host: '***',",
"2017-01-25T16:12:34.711205213Z stdout: dbname: 'src',",
"2017-01-25T16:12:34.711214336Z stdout: includeDocs: true,",
"2017-01-25T16:12:34.711223392Z stdout: overwrite: false,",
"2017-01-25T16:12:34.711233436Z stdout: package_endpoint: '10.143.15.111:11000',",
"2017-01-25T16:12:34.711242728Z stdout: lifecycleEvent: 'CREATE',",
"2017-01-25T16:12:34.711251853Z stdout: triggerName: '/_/newTrackingEvent',",
"2017-01-25T16:12:34.711261256Z stdout: password: '***' }",
"2017-01-25T16:12:34.810688295Z stdout: cloudant trigger feed: done http request",
"2017-01-25T16:12:34.811401516Z stdout: { id: ':ptitzler_org_dev:newTrackingEvent',",
"2017-01-25T16:12:34.811430393Z stdout: accounturl: 'https://***-bluemix.cloudant.com',",
"2017-01-25T16:12:34.811441235Z stdout: dbname: 'src',",
"2017-01-25T16:12:34.811451032Z stdout: user: '***',",
"2017-01-25T16:12:34.811460676Z stdout: pass: '***',",
"2017-01-25T16:12:34.81147041Z  stdout: host: '***-bluemix.cloudant.com',",
"2017-01-25T16:12:34.811490203Z stdout: protocol: 'https',",
"2017-01-25T16:12:34.811500637Z stdout: apikey: '***',",
"2017-01-25T16:12:34.811518951Z stdout: callback: { action: { name: '/ptitzler_org_dev/newTrackingEvent' } },",
"2017-01-25T16:12:34.811528767Z stdout: maxTriggers: -1,",
"2017-01-25T16:12:34.811537989Z stdout: triggersLeft: -1,",
"2017-01-25T16:12:34.811558803Z stdout: retriesLeft: 10 }"

创建规则:

$ wsk rule create logEvent newTrackingEvent displayEvent
ok: created rule logEvent

在 Cloudant 中创建新文档

{
 "_id": "0689f19a88edd98512a33df24ab084a4",
 "myproperty": 123
}

生成的 displayEvent 活动日志输出仅包括文档元数据,但不包括文档本身:

{

"duration": 64,
"name": "displayEvent",
"subject": "***",
"activationId": "8d81abfb258e4752bbe74d79601c5a7e",
"publish": false,
"annotations": [
    {
        "key": "limits",
        "value": {
            "timeout": 60000,
            "memory": 256,
            "logs": 10
        }
    },
    {
        "key": "path",
        "value": "ptitzler_org_dev/displayEvent"
    }
],
"version": "0.0.4",
"response": {
    "result": {
        "payload": {
            "seq": "10-g1...4",
            "id": "0689f19a88edd98512a33df24ab084a4",
            "changes": [
                {
                    "rev": "1-bf5fdf2758669105decf1fa0c6853626"
                }
            ],
            "dbname": "src"
        }
    },
    "success": true,
    "status": "success"
},
"end": 1485361317416,
"logs": [ ],
"start": 1485361317352,
"namespace": "ptitzler_org_dev"
}

我错过了什么?

4

1 回答 1

1

不再支持 includeDocs。请参阅以下内容:https ://developer.ibm.com/openwhisk/2016/12/05/cloudant-feed-change-no-longer-support-includedocs/

于 2017-01-25T18:12:38.400 回答