2024-01-01 17:49:27 +08:00
|
|
|
|
package kis
|
2023-12-31 18:04:28 +08:00
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"kis-flow/config"
|
|
|
|
|
)
|
|
|
|
|
|
2024-01-01 17:49:27 +08:00
|
|
|
|
// Function 流式计算基础计算模块,KisFunction是一条流式计算的基本计算逻辑单元,
|
2023-12-31 18:04:28 +08:00
|
|
|
|
// 任意个KisFunction可以组合成一个KisFlow
|
2024-01-01 17:49:27 +08:00
|
|
|
|
type Function interface {
|
2023-12-31 18:04:28 +08:00
|
|
|
|
// Call 执行流式计算逻辑
|
2024-01-01 17:49:27 +08:00
|
|
|
|
Call(ctx context.Context, flow Flow) error
|
2023-12-31 18:04:28 +08:00
|
|
|
|
|
|
|
|
|
// SetConfig 给当前Function实例配置策略
|
|
|
|
|
SetConfig(s *config.KisFuncConfig) error
|
|
|
|
|
// GetConfig 获取当前Function实例配置策略
|
|
|
|
|
GetConfig() *config.KisFuncConfig
|
|
|
|
|
|
|
|
|
|
// SetFlow 给当前Function实例设置所依赖的Flow实例
|
2024-01-01 17:49:27 +08:00
|
|
|
|
SetFlow(f Flow) error
|
2023-12-31 18:04:28 +08:00
|
|
|
|
// GetFlow 获取当前Functioin实力所依赖的Flow
|
2024-01-01 17:49:27 +08:00
|
|
|
|
GetFlow() Flow
|
2023-12-31 18:04:28 +08:00
|
|
|
|
|
2024-01-03 10:16:54 +08:00
|
|
|
|
// CreateId 给当前Funciton实力生成一个随机的实例KisID
|
|
|
|
|
CreateId()
|
|
|
|
|
// GetId 获取当前Function的FID
|
|
|
|
|
GetId() string
|
2023-12-31 18:04:28 +08:00
|
|
|
|
// GetPrevId 获取当前Function上一个Function节点FID
|
|
|
|
|
GetPrevId() string
|
|
|
|
|
// GetNextId 获取当前Function下一个Function节点FID
|
|
|
|
|
GetNextId() string
|
|
|
|
|
|
|
|
|
|
// Next 返回下一层计算流Function,如果当前层为最后一层,则返回nil
|
2024-01-01 17:49:27 +08:00
|
|
|
|
Next() Function
|
2023-12-31 18:04:28 +08:00
|
|
|
|
// Prev 返回上一层计算流Function,如果当前层为最后一层,则返回nil
|
2024-01-01 17:49:27 +08:00
|
|
|
|
Prev() Function
|
2023-12-31 18:04:28 +08:00
|
|
|
|
// SetN 设置下一层Function实例
|
2024-01-01 17:49:27 +08:00
|
|
|
|
SetN(f Function)
|
2023-12-31 18:04:28 +08:00
|
|
|
|
// SetP 设置上一层Function实例
|
2024-01-01 17:49:27 +08:00
|
|
|
|
SetP(f Function)
|
2023-12-31 18:04:28 +08:00
|
|
|
|
}
|