You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwhisk.apache.org by OpenWhisk Team Slack <ra...@apache.org> on 2010/01/01 00:01:01 UTC

[slack-digest] [2022-01-13] #general

2022-01-13 02:25:30 UTC - Matt Welke: Got my first taste of the OpenWhisk programming model tonight. Up until now, I've only been using it as FaaS where I just create web actions. Or the simple version of the bot above where I have an action that isn't a web action but is just triggered by a periodic trigger (aka alarm), runs, and doesn't trigger any events of its own. But now, I got to play around with triggers and make an event based system.

The bot I described above was originally set up as a periodic trigger linked to a single action which did the web scraping and sent data to the Twitter API. I now want to expand it to do that, but also stream a row into BigQuery on Google Cloud Platform so that I can build a public dataset on BigQuery for myself and others to use. The docs on triggers were a really good read and the JavaScript OpenWhisk client had good docs in its README to help me get up and running invoking a custom trigger.
+1 : Rodric Rabbah
https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1642040730003200
----
2022-01-13 02:25:41 UTC - Matt Welke: My new architecture to enable my use case looks like this:
https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1642040741003500
----
2022-01-13 02:26:17 UTC - Matt Welke: Legend:

Green oval = trigger
Blue rounded rectangle = sequence
Purple rectangle = action
Grey rectangle = action yet to come
https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1642040777004200
----
2022-01-13 02:28:23 UTC - Matt Welke: I wanted to use Java because I like the dev experience having a compiler to help me (and I need to practice my Java for work anyways), but I noticed there wasn't a Java OpenWhisk client published. If I wanted to manually invoke my trigger, I'd have to write low level Java code to interact with the OW API. But I was able to grab the Node.js code from the README for the JS client and make a little "glue" action. It may as well be a pre-built action for this use case. It just passes params through while invoking a custom trigger:

```var openwhisk = require('openwhisk');

async function main(params) {
    const triggerName = 'free-ebook-of-the-day-released';
    
    try {
        var ow = openwhisk();
        const triggerResult = await ow.triggers.invoke({
            name: triggerName,
            params,
        });
        <http://console.info|console.info>(`invoked trigger "${triggerName}"`, triggerResult);
        return {};
    } catch (err) {
        console.error(`failed to invoke trigger "${triggerName}"`, err);
        return {};
    }
}```
https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1642040903006500
----
2022-01-13 02:28:40 UTC - Matt Welke: Now, I'm well-positioned to build the action to also save the data in BigQuery later.
https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1642040920006900
----