https://github.com/michaelmerg/serverless-function-runtime-java
https://github.com/michaelmerg/serverless-function-runtime-java
functions-as-a-service java serverless serverless-functions
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/michaelmerg/serverless-function-runtime-java
- Owner: michaelmerg
- License: mit
- Created: 2018-02-07T07:13:32.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-25T18:29:06.000Z (about 8 years ago)
- Last Synced: 2025-04-06T04:41:18.584Z (12 months ago)
- Topics: functions-as-a-service, java, serverless, serverless-functions
- Language: Java
- Size: 72.3 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Serverless function runtime for Java
[](https://travis-ci.org/michaelmerg/serverless-function-runtime-java)
Java 8 template for [OpenFaas](https://github.com/openfaas/faas)
## Quick Start
Pull template from GitHub:
```
$ faas-cli template pull https://github.com/michaelmerg/serverless-function-runtime-java
```
Create new function:
```
$ faas-cli new --lang java-gradle java-echo
```
Build function:
```
$ faas-cli build -f java-echo.yml
```
Deploy function:
```
$ faas-cli deploy -f java-echo.yml
```
Invoke function:
```
$ faas-cli invoke java-echo
```
## Overview
There are two different supported handler interfaces. The basic request handler supports simple Java types or a POJO types as input and output. With the streaming request handler you can handle the input and output as byte streams.
### Request handler
```java
public class Handler implements RequestHandler {
@Override
public String handle(String input, Context context) {
// Add function code here
return input;
}
}
```
### Streaming request handler
```Java
public class StreamingHandler implements StreamingRequestHandler {
@Override
public void handle(InputStream input, OutputStream output, Context context) {
// read input stream
// write output stream
}
}
```