All Projects → IBM → ibm-cloud-functions-action-trigger-rule

IBM / ibm-cloud-functions-action-trigger-rule

Licence: Apache-2.0 license
Simple demo showing Apache OpenWhisk actions, triggers, and rules with IBM Cloud Functions.

Programming Languages

shell
77523 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ibm-cloud-functions-action-trigger-rule

ibm-cloud-functions-rest-api-trigger
IBM Cloud Functions building block - HTTP REST Trigger - This project provides a starting point for handling events from REST API calls with IBM Cloud Functions powered by Apache OpenWhisk.
Stars: ✭ 17 (+6.25%)
Mutual labels:  openwhisk, openwhisk-getting-started, openwhisk-building-block, ibm-cloud-functions
ibm-cloud-functions-serverless-ocr-openchecks
Serverless bank check deposit processing with object storage and optical character recognition using Apache OpenWhisk powered by IBM Cloud Functions. See the Tech Talk replay for a demo.
Stars: ✭ 40 (+150%)
Mutual labels:  openwhisk, openwhisk-getting-started, ibm-cloud-functions
slack-chatbot-database-watson
Code for the solution tutorial "Build a database-driven Slackbot" (chatbot) with a custom extension in IBM Watson Assistant
Stars: ✭ 23 (+43.75%)
Mutual labels:  openwhisk, ibm-cloud-functions
openwhisk-runtime-docker
Apache OpenWhisk SDK for building Docker "blackbox" runtimes
Stars: ✭ 23 (+43.75%)
Mutual labels:  openwhisk
fiware-meteoroid
Meteoroid realizes integrating Function as a Service(FaaS) capabilities in FIWARE. It provides a management interface specialized for FaaS and FIWARE.
Stars: ✭ 13 (-18.75%)
Mutual labels:  openwhisk
wskdebug
Debugging and live development tool for Apache OpenWhisk - MOVED >>
Stars: ✭ 17 (+6.25%)
Mutual labels:  openwhisk
text-bot-openwhisk
DEPRECATED: this repo is no longer actively maintained
Stars: ✭ 12 (-25%)
Mutual labels:  openwhisk
openwhisk-runtime-java
Apache OpenWhisk Runtime Java supports Apache OpenWhisk functions written in Java and other JVM-hosted languages
Stars: ✭ 43 (+168.75%)
Mutual labels:  openwhisk
openwhisk-runtime-python
Apache OpenWhisk Runtime Python supports Apache OpenWhisk functions written in Python
Stars: ✭ 39 (+143.75%)
Mutual labels:  openwhisk
faas-tutorial
Java FaaS demos with OpenWhisk and OpenShift
Stars: ✭ 43 (+168.75%)
Mutual labels:  openwhisk
openwhisk-runtime-go
Apache OpenWhisk Runtime Go supports Apache OpenWhisk functions written in Go
Stars: ✭ 31 (+93.75%)
Mutual labels:  openwhisk
logistics-wizard
The Logistics Wizard is an end-to-end, smart supply chain management solution that showcases how to execute hybrid cloud, microservices, and predictive data analytics in the real world.
Stars: ✭ 99 (+518.75%)
Mutual labels:  openwhisk
assistant-with-discovery-openwhisk
DEPRECATED: this repo is no longer actively maintained
Stars: ✭ 21 (+31.25%)
Mutual labels:  openwhisk
openwhisk-catalog
Curated catalog of Apache OpenWhisk packages to interface with event producers and consumers
Stars: ✭ 30 (+87.5%)
Mutual labels:  openwhisk
concierge
A Watson powered conversational bot for small businesses
Stars: ✭ 15 (-6.25%)
Mutual labels:  openwhisk
Openwhisk
Apache OpenWhisk is an open source serverless cloud platform
Stars: ✭ 5,499 (+34268.75%)
Mutual labels:  openwhisk
openwhisk-deploy-openshift
[DEPRECATED] - This project can be used to deploy Apache OpenWhisk to the OpenShift platform
Stars: ✭ 22 (+37.5%)
Mutual labels:  openwhisk
openwhisk-package-kafka
Apache OpenWhisk package for communicating with Kafka or Message Hub
Stars: ✭ 35 (+118.75%)
Mutual labels:  openwhisk
serverless-company
Serverless. FaaS. Spring Boot. Spring Cloud Function
Stars: ✭ 15 (-6.25%)
Mutual labels:  openwhisk
openwhisk-runtime-dotnet
Apache OpenWhisk Runtime .Net supports Apache OpenWhisk functions written in .Net languages
Stars: ✭ 23 (+43.75%)
Mutual labels:  openwhisk

IBM Cloud Functions - Your first Action, Trigger, and Rule

Read this in other languages: 한국어.

Simple demo showing Apache OpenWhisk actions, triggers, and rules on the IBM Cloud Functions platform. Created for the Build a cloud native app with Apache OpenWhisk webinar. First, you'll need an IBM Cloud account and the latest OpenWhisk command line tool.

High level diagram

Action: handler.js

This simple JavaScript function (called an action in OpenWhisk) accepts a params argument and writes information that can be retrieved from the Cloud Functions activation log and/or the IBM Cloud Functions monitoring console. It also returns a JSON object with the current date.

First, open a terminal window to start polling the activation log. The console.log statements in the action will be logged here, which you can stream with the following command:

ibmcloud fn activation poll

In another terminal window, upload the action file as a Cloud Function using the following command:

ibmcloud fn action create handler handler.js

Then invoke it manually. This will echo the resulting JSON message to the current window and log the activation in the other window.

ibmcloud fn action invoke --blocking handler

Trigger: every-20-seconds

This trigger uses the built-in alarm package feed to fire events every 20 seconds. This is specified through cron syntax in the cron parameter. The maxTriggers parameter ensures that it only fires for five minutes (15 times), rather than indefinitely.

Create it with the following command:

ibmcloud fn trigger create every-20-seconds \
  --feed  /whisk.system/alarms/alarm \
  --param cron '*/20 * * * * *' \
  --param maxTriggers 15

Rule: invoke-periodically

This rule shows how the every-20-seconds trigger can be declaratively mapped to the handler.js action. Notice that it's named somewhat abstractly so that if we wanted to use a different trigger - perhaps something that fires every minute instead - we could still keep the logical name.

Create the rule with the following command:

ibmcloud fn rule create \
  invoke-periodically \
  every-20-seconds \
  handler

At this point you can check the activation log that you are tailing in the other window to confirm that the action is invoked by the trigger.

Installation instructions

Cloud Functions developers will often automate the creation of actions, triggers, and rules as they iterate on their application. The convention that has arisen in many sample apps is to use a deploy.sh script, often in conjunction with a local.env file to externalize environment variables.

The script can be used to set up, tear down, and see the current configuration:

./deploy.sh --install
./deploy.sh --uninstall
./deploy.sh --env # Not used in this demo

Note: deploy.sh will be replaced with wskdeploy in the future. wskdeploy uses a manifest to deploy declared triggers, actions, and rules to OpenWhisk.

Troubleshooting

Check for errors first in the activation log. Tail the log on the command line with ibmcloud fn activation poll or drill into details visually with the Cloud Functions monitoring console.

If the error is not immediately obvious, make sure you have the latest version of the wsk CLI installed. If it's older than a few weeks, download an update.

ibmcloud fn property get --cliversion

License

Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].