Apache OpenWhisk Runtime for Ballerina
March 7, 2018 ยท View on GitHub
This repository contains the Ballerina runtime extension for Apache OpenWhisk serverless platform.
Prerequisites
The following prerequisites are needed to try this out:
- Vagrant >= v2.0.1
- OpenWhisk
- OpenWhisk CLI
- Golang >= v1.9.2 (if requires to build the Docker image)
Quick Start Guide
-
Install OpenWhisk using Vagrant:
# Clone OpenWhisk git repository git clone --depth=1 https://github.com/apache/incubator-openwhisk.git openwhisk # Switch the directory to tools/vagrant cd openwhisk/tools/vagrant # Start OpenWhisk instance vagrant up -
Install OpenWhisk CLI by following it's installation guide: https://github.com/apache/incubator-openwhisk-cli
-
Create a Ballerina function file with the following content and name it as hello-function.bal:
import ballerina.io; function main (string[] args) { var output = { "hello": "world!" }; io:println(output); } -
Create an OpenWhisk action for the above Ballerina function using the OpenWhisk CLI:
wsk action create hello-function hello-function.bal --docker imesh/ballerina-action -
Invoke the hello-function using the OpenWhisk CLI:
wsk action invoke hello-function --result { "hello": "world!" }