Apache OpenWhisk Runtime Ballerina supports Apache OpenWhisk functions written in Ballerina

Clone this repo:


  1. e4dd62c chore: fix spelling and grammar (#24) by John Bampton · 3 years, 2 months ago master
  2. 0af6e83 migration from travis-ci.org to travis-ci.com (#23) by David Grove · 3 years, 4 months ago
  3. bfd72f0 gradle version 5 (#21) by David Grove · 4 years, 7 months ago
  4. 9800d62 add .asf.yaml to configure github metadata (#20) by David Grove · 4 years, 7 months ago
  5. 16251c3 tlp: remove incubator references and disclaimer (#18) by David Grove · 4 years, 8 months ago

Apache OpenWhisk Runtime for Ballerina

License Build Status

This repository contains the Ballerina runtime for the Apache OpenWhisk serverless platform.


The following prerequisites are needed to try this out:

Creating a Ballerina function

Create a file hello.bal for your Ballerina function with the following code:

import ballerina/io;

public function main(json jsonInput) returns json {
  json output = { "response": "hello-world"};
  return output;

The Ballerina file must include a function called main. The absence of main causes the Ballerina compiler to omit generation of the executable. You may have more than one entry point in your source file however (e.g., a main and a run) and use the standard OpenWhisk mechanism to specify other functions to run on entry (e.g., --main <other function name> when using the wsk action create CLI command). The function must accept a JSON object and return a JSON object to be compliant with the OpenWhisk action interface.

Compiling your function

Run the Ballerina compiler to build your function.

ballerina build hello.bal

This generates an executable hello.balx. You will use this binary to create the OpenWhisk action.

Creating and invoking your Ballerina action

Use the OpenWhisk wsk CLI to create your Ballerina action.

wsk action create hello hello.balx --docker openwhisk/action-ballerina-v0.990.2

Now you're ready to invoke the action:

wsk action invoke hello --result
  "response": "hello-world"

You can learn more about working with OpenWhisk Actions here.

Developing the Ballerina runtime for OpenWhisk

To build the Ballerina runtime, you need an OpenWhisk snapshot release which you can install as follows:

./gradlew install

where $OPENWHISK_HOME is an environment variable that points to your OpenWhisk directory.

The Ballerina runtime is built with the Gradle wrapper gradlew.

./gradlew distDocker

You can also use gradlew to run all the unit tests.

./gradlew :tests:test

Or to run a specific test.

./gradlew :tests:test --tests *ActionContainerTests*

This project can be imported into IntelliJ for development and testing. Import the project as a Gradle project, and make sure your working directory is the root directory for this repository.