2023-12-31 18:04:28 +08:00
|
|
|
package function
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-04-16 15:11:23 +08:00
|
|
|
|
2024-03-26 14:54:50 +08:00
|
|
|
"github.com/aceld/kis-flow/kis"
|
|
|
|
"github.com/aceld/kis-flow/log"
|
2023-12-31 18:04:28 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type KisFunctionE struct {
|
|
|
|
BaseFunction
|
|
|
|
}
|
|
|
|
|
2024-01-26 17:27:29 +08:00
|
|
|
func NewKisFunctionE() kis.Function {
|
|
|
|
f := new(KisFunctionE)
|
|
|
|
|
2024-04-15 17:50:02 +08:00
|
|
|
// Initialize metaData
|
2024-01-26 17:27:29 +08:00
|
|
|
f.metaData = make(map[string]interface{})
|
|
|
|
|
|
|
|
return f
|
|
|
|
}
|
|
|
|
|
2024-01-01 17:49:27 +08:00
|
|
|
func (f *KisFunctionE) Call(ctx context.Context, flow kis.Flow) error {
|
2024-04-15 11:17:47 +08:00
|
|
|
log.Logger().DebugF("KisFunctionE, flow = %+v\n", flow)
|
2023-12-31 18:04:28 +08:00
|
|
|
|
2024-04-15 17:50:02 +08:00
|
|
|
// Route to the specific computing Function through KisPool
|
2024-01-04 16:36:36 +08:00
|
|
|
if err := kis.Pool().CallFunction(ctx, f.Config.FName, flow); err != nil {
|
2024-04-15 11:17:47 +08:00
|
|
|
log.Logger().ErrorFX(ctx, "Function Called Error err = %s\n", err)
|
2024-01-04 16:36:36 +08:00
|
|
|
return err
|
2024-01-03 17:22:35 +08:00
|
|
|
}
|
2023-12-31 18:04:28 +08:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|