Supports fast fork
- Deploy OpenFaaS
- Install OpenFaaS CLI
Pull template and create a new function
$ faas-cli template pull https://github.com/ganesshkumar/openfaas-template-java
$ faa-cli new --lang java8-gradle java-function
Build and deploy to OpenFaaS
$ faas-cli build -f java-function.yml
$ faas-cli deploy -f java-function.yml
Test your function
$ echo test | faas-cli invoke java-function
You said: openfaas
- Once you execute
faas-cli newcommand, a new folder is created for your function. - This folder is nothing but a gradle project with a rudimentary
build.gradlefile. - There must be a class
function.Handerwith a methodfunction(String requesBody, String httpMethod)which is the starting point of your function.
- The template looks for
function.Handlerclass which has a method calledfunction
package function;
public class Handler {
public String function(String input, String method) {
return "You said: " + input;
}
}Note: These willbe addressed in a better way