This is a small example illustrating this blog post about doing Serverless functions in Kotlin.
First I recommend to read this article by Mike Roberts from Martin Fowler website to get a bit more understanding on what is a Serverless architecture.
Them we should take a loot to the System Overview of Apache Openwhisk.
You need to have OpenWhisk up and running, them fist build this function:
$ mvnw package
Now you could add an action to OpenWhisk with:
$ cd target
$ wsk action create Fibonacci KotlinServerless-1.0-SNAPSHOT-jar-with-dependencies.jar --main \
org.learning.by.example.serverless.kotlin.FibonacciKt
To test the new action just run:
$ wsk action invoke --result Fibonacci --param numbers 5
This will output something like:
{
"result": [
1,
1,
2,
3,
5
]
}