Skip to content
Swarvanu Sengupta edited this page Jul 29, 2019 · 4 revisions

1. What is a minimal definition for a faas-flow fucntion?

Below is a minimal definition for faas-flow function in the stack.yml file:

  my-faas-flow:
    lang: faas-flow
    handler: ./my-faas-flow
    image: my-faas-flow:latest
    labels:
      faas-flow: 1
    environment:
      write_debug: true
      combine_output: false
      gateway: "gateway.openfaas:8080" # use "gateway:8080" for swarm
      enable_tracing: false 
      enable_hmac: false

In the my-faas-flow/handler.go file:

package function

import (
    "fmt"
    faasflow "github.com/s8sg/faas-flow"
)
func Define(flow *faasflow.Workflow, context *faasflow.Context) (err error) {
     flow.SyncNode().Modify(func(data []byte) ([]byte, error) {
			data = []byte("you said " + string(data))
			return data, nil
		})
     return nil
}

func DefineStateStore() (faasflow.StateStore, error) { return nil, nil }
func DefineDataStore() (faasflow.DataStore, error) { return nil, nil }
Clone this wiki locally