Sebas
Sebas

Reputation: 21532

Implement Cloudant change feed on local OpenWhisk

I have a local install of OpenWhisk (vagrant based), and a local install of Cloudant (the free one from the ibmcom/cloudant-developer container).

Both work separately as expected.

Now, using Bluemix, I can use the /whisk.system/cloudant package to use its feeds in my triggers, to for example watch for changes on a specific database.

Locally, this package is missing. I tried to copy the actions and feeds I needed using wsk action get /whisk.system/cloudant/changes (for example) but it seems there's another missing piece of the puzzle as the feed action refers to a cloudanttriggers location I never saw before:

function cloudantHelper(endpoint, verb, name, input) {
    var url = 'http://' + endpoint + '/cloudanttriggers/' + name;
    var promise = new Promise(function(resolve, reject) {
        request({
            method : verb,
            url : url,
            json: input
        }, function(error, response, body) {
            ...
        });
    });

    return promise;
}

Any idea how to implement Cloudant Change feed on a local openwhisk installation?

Upvotes: 0

Views: 213

Answers (1)

markusthoemmes
markusthoemmes

Reputation: 3120

TLDR: You're looking for the CloudantProvider. See https://github.com/openwhisk/openwhisk-package-cloudant

To use the Cloudant feed OpenWhisk needs an additional component to actually listen to changes in Cloudant (the CouchDB _changes feed essentially) and fire the triggers in OpenWhisk. The feed-action you see talks to that service to setup a handler, which listens to _changes in the database you provide. It then fires the trigger specified once it receives a change.

Upvotes: 2

Related Questions