-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from fnproject/mww-190404-reverse-up
Update Java FDK string-reverse example
- Loading branch information
Showing
7 changed files
with
104 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
# `fn` Java FDK Example Projects | ||
# Fn Java FDK Example Projects | ||
|
||
In this directory you will find some example projects demonstrating different | ||
features of the `fn` Java FDK: | ||
features of the Fn Java FDK: | ||
|
||
* Plain java code support (`string-reverse`) | ||
* Functional testing of your functions (`regex-query` and `qr-code`) | ||
* Built-in JSON coercion (`regex-query`) | ||
* [InputEvent and OutputEvent](/docs/DataBinding.md) handling (`qr-code`) | ||
|
||
## 1. String reverse | ||
## (1) [String reverse](string-reverse/README.md) | ||
|
||
This function takes a string and returns the reverse of the string. | ||
The `fn` Java FDK runtime will handle marshalling data into your | ||
functions without the function having to have any knowledge of the FDK API. | ||
The Fn Java FDK handles marshalling data into your | ||
functions without the function having any knowledge of the FDK API. | ||
|
||
## 2. Regex query | ||
## (2) Regex query | ||
|
||
This function takes a JSON object containing a `text` field and a `regex` | ||
field and return a JSON object with a list of matches in the `matches` | ||
field. It demonstrates the builtin JSON support of the fn Java | ||
wrapper (provided through Jackson) and how the platform handles serialisation | ||
wrapper (provided through Jackson) and how the platform handles serialization | ||
of POJO return values. | ||
|
||
## 3. QR Code gen | ||
## (3) QR Code gen | ||
|
||
This function parses the query parameters of a GET request (through the | ||
`InputEvent` passed into the function) to generate a QR code. It demonstrates | ||
the `InputEvent` and `OutputEvent` interfaces which provide low level | ||
access to data entering the `fn` Java FDK. | ||
|
||
## 4. Asynchronous thumbnails generation | ||
## (4) Asynchronous thumbnails generation | ||
|
||
This example showcases the Fn Flow asynchronous execution API, by | ||
creating a workflow that takes an image and asynchronously generates three | ||
thumbnails for it, then uploads them to an object storage. | ||
|
||
## 5. Gradle build | ||
## (5) Gradle build | ||
This shows how to use Gradle to build functions using the Java FDK. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
name: fn-example/string-reverse | ||
version: 0.0.1 | ||
schema_version: 20180708 | ||
name: string-reverse | ||
version: 0.0.2 | ||
runtime: java | ||
timeout: 30 | ||
format: http | ||
cmd: com.fnproject.fn.examples.StringReverse::reverse | ||
path: /reverse | ||
build_image: fnproject/fn-java-fdk-build:jdk11-1.0.87 | ||
run_image: fnproject/fn-java-fdk:jre11-1.0.87 | ||
cmd: com.example.fn.StringReverse::reverse | ||
triggers: | ||
- name: string-reverse | ||
type: http | ||
source: /string-reverse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/string-reverse/src/main/java/com/example/fn/StringReverse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example.fn; | ||
|
||
public class StringReverse { | ||
public String reverse(String str) { | ||
return new StringBuilder(str).reverse().toString(); | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
examples/string-reverse/src/main/java/com/fnproject/fn/examples/StringReverse.java
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...fnproject/examples/StringReverseTest.java → ...example/fn/testing/StringReverseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters