kis-flow/test/faas/faas_demo1.go

29 lines
704 B
Go
Raw Normal View History

2024-01-09 17:30:58 +08:00
package faas
import (
"context"
"fmt"
2024-03-26 14:54:50 +08:00
"github.com/aceld/kis-flow/kis"
2024-01-09 17:30:58 +08:00
)
// type FaaS func(context.Context, Flow) error
func FuncDemo1Handler(ctx context.Context, flow kis.Flow) error {
fmt.Println("---> Call funcName1Handler ----")
2024-01-26 17:27:29 +08:00
fmt.Printf("Params = %+v\n", flow.GetFuncParamAll())
2024-01-09 17:30:58 +08:00
for index, row := range flow.Input() {
// 打印数据
str := fmt.Sprintf("In FuncName = %s, FuncId = %s, row = %s", flow.GetThisFuncConf().FName, flow.GetThisFunction().GetId(), row)
fmt.Println(str)
// 计算结果数据
resultStr := fmt.Sprintf("data from funcName[%s], index = %d", flow.GetThisFuncConf().FName, index)
// 提交结果数据
_ = flow.CommitRow(resultStr)
}
return nil
}