Both the provided platform and described language implement convenient way for explicit and type-safe composition of cloud functions.
For example the following scheme describes two services and their communication.
package test
type Source = {
name :: String
price :: Float
}
type Prepared = {
name :: String
description :: String
category :: Integer
price :: Float
}
type Product = {
id :: Integer
name :: String
description :: String
category :: Integer
price :: Float
}
type Error = {
error :: String
}
github.com/project/prepare[go] :: Source -> Either Prepared Error
github.com/project/save[go] :: Prepared -> Either Product Error
create = prepare >>= save
invoke(create,)
Anzer utility currently supports only Apache OpenWhisk and Golang.
See the documentation for details.
- Install docker for your system.
- Download and install wsk utility from github page.
- Find working Apache OpenWhisk instance.
- Register at cloud.ibm.com.
- Follow the instruction at cloud.ibm.com/openwhisk/learn/cli.
- Check the settings with
wsk action list
. Also~/.wskprops
must contain something like the following.
APIHOST=eu-gb.functions.cloud.ibm.com
NAMESPACE=_
AUTH=short_token
APIGW_ACCESS_TOKEN=big_token
Download suitable binary from realizes page. For example for linux:
sudo curl -L "https://github.com/tariel-x/anzer/releases/download/latest/linux_amd64_anzer" -o /usr/local/bin/anzer
sudo chmod +x /usr/local/bin/anzer
anzer help
For OS X:
sudo curl -L "https://github.com/tariel-x/anzer/releases/download/latest/darwin_amd64_anzer" -o /usr/local/bin/anzer
sudo chmod +x /usr/local/bin/anzer
anzer help
git clone https://github.com/tariel-x/anzer.git
cd anzer
go install
anzer help
git clone https://github.com/tariel-x/anzer-example.git
cd anzer-example
Make copy of the envs.yaml.dist
and edit according to your CouchDB settings.
cp envs.yaml.dist envs.yaml
nano envs.yaml
anzer build -p wsk -i etl.anz --envs envs.yaml
The output of utility would be name of functions sequence in OpenWhisk.
wsk -i api create /etl post /guest/etl_sequence --response-type json
Make request like the following:
curl -X POST \
http://your.whisk.com:9001/api/23bc46b1-71f6-4ed5-8c54-816aa4f8c502/etl \
-H 'Content-Type: application/json' \
-d '{
"name": "Opel",
"model": "Astra;J",
"phone": "79095544445",
"price": 500.50,
"photos": [
"http://origin.org/path/image.jpeg"
],
"year": 2014
}'
The expected result is:
{
"car": {
"brand": "Opel",
"model": "Astra"
},
"err": null,
"id": 38081
}
- Full support of OR-types and pattern-matching in the scheme.
- Remake subsystem for building functions.