-
Notifications
You must be signed in to change notification settings - Fork 42
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 #91 from fission/fission-headers-query-support
Add support for inputs specifying task metadata
- Loading branch information
Showing
12 changed files
with
237 additions
and
57 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,29 +1,64 @@ | ||
# Simple Examples | ||
This directory contains two simple example workflows (and two whales!), along with the required functions. | ||
This directory contains multiple simple example workflows (and whales!), along with the required functions. | ||
The intention of each workflow is to show-off and explain a concept in Fission Workflows | ||
|
||
## Setup | ||
- Make sure that you have a running Fission Cluster with the workflow engine, see the [readme](../../README.md) for details. | ||
- Deploy both the functions, using the [deploy.sh](./deploy.sh) script, or run the commands listed there manually. | ||
|
||
### Example: Echowhale | ||
The 'echowhale' workflow is a minimal workflow, consisting of whale echoing the input. | ||
## Examples | ||
|
||
|
||
### Echowhale | ||
The `echowhale` workflow is a minimal workflow, consisting of whale echoing the input. | ||
The main feature it shows is that a workflow from the user's view the same as a Fission function. | ||
|
||
To invoke: | ||
Run: | ||
```bash | ||
curl -XPOST -d 'Whale you echo?' $FISSION_ROUTER/fission-function/echowhale | ||
curl -XPOST -d 'Whale you echo?' ${FISSION_ROUTER}/fission-function/echowhale | ||
``` | ||
|
||
### Example: Fortunewhale | ||
The fortunewhale workflow consists of multiple steps, generating a 'fortune' and passing it through the whalesay function that was used in the first workflow. | ||
### Fortunewhale | ||
The `fortunewhale` workflow consists of multiple steps, generating a 'fortune' and passing it through the whalesay function that was used in the first workflow. | ||
The features introduced in this example: | ||
- Dependencies between tasks | ||
- Mapping a task's output to another task's input | ||
- The 'noop' internal function, which is a function executed within the engine itself. | ||
|
||
To invoke: | ||
Run: | ||
```bash | ||
curl -XPOST $FISSION_ROUTER/fission-function/fortunewhale | ||
curl -XPOST ${FISSION_ROUTER}/fission-function/fortunewhale | ||
``` | ||
|
||
### Maybewhale | ||
The `maybewhale` workflow consists of a simple if-else condition. | ||
Depending on the length of the input, the workflow transforms the input. | ||
If the input is smaller than 20 characters, the workflow will run the `whalesay` task. | ||
If not, it will simply propagate the user input. | ||
|
||
Run: | ||
```bash | ||
# This will wrap the input in a whale, because the input is < 20 | ||
curl -XPOST -d 'Whale you echo?' ${FISSION_ROUTER}/fission-function/maybewhale | ||
|
||
# This will simply echo the input, because the input is >= 20. | ||
curl -XPOST -d 'Whale you echo this way too long message?' ${FISSION_ROUTER}/fission-function/maybewhale | ||
``` | ||
|
||
### Example: | ||
### Metadatawhale | ||
The `metadatawhale` workflow shows how to add metadata (headers, query values) to tasks. | ||
|
||
Run: | ||
```bash | ||
curl -XPOST ${FISSION_ROUTER}/fission-function/metadatawhale | ||
``` | ||
|
||
### Nestedwhale | ||
The `nestedwhale` workflow is surprisingly... empty. | ||
The principle that 'workflows are fission functions', allows workflows to call other workflows just like you would call regular Fission Functions. | ||
In this workflow, we generate a fortune and pass it to the dedicated whale echoing workflow: `echowhale`. | ||
|
||
Run | ||
```bash | ||
curl -XPOST ${FISSION_ROUTER}/fission-function/nestedwhale | ||
``` |
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,3 +1,4 @@ | ||
# This whale shows how to access and reference with workflow parameters | ||
apiVersion: 1 | ||
output: echowhale | ||
tasks: | ||
|
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,19 @@ | ||
#!/bin/sh | ||
|
||
# fortune - generate wise words | ||
# | ||
# Output: string (plain text) | ||
|
||
# TODO move this to the build step once the binary environment is a v2 environment | ||
if ! hash fortune 2>/dev/null; then | ||
apk add fortune > /dev/null | ||
fi | ||
|
||
# Pretty useless, but used to show headers | ||
prefix=${HTTP_PREFIX} | ||
|
||
if [ ! -z "${prefix}" ] ; then | ||
printf "${prefix}" | ||
fi | ||
|
||
fortune -s |
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,3 +1,4 @@ | ||
# A whale that shows off how a if-condition works in a workflow | ||
apiVersion: 1 | ||
output: PassAlong | ||
tasks: | ||
|
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,8 @@ | ||
# A whale that shows off how to add metadata (e.g. headers, query) to your fission function | ||
apiVersion: 1 | ||
output: PrefixedFortune | ||
tasks: | ||
PrefixedFortune: | ||
run: fortune | ||
inputs: | ||
header_prefix: "Whale says:" |
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
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
Oops, something went wrong.