2024-01-01 17:49:27 +08:00
|
|
|
package test
|
2023-12-30 17:38:08 +08:00
|
|
|
|
|
|
|
import (
|
2024-03-26 14:54:50 +08:00
|
|
|
"github.com/aceld/kis-flow/common"
|
|
|
|
"github.com/aceld/kis-flow/config"
|
|
|
|
"github.com/aceld/kis-flow/log"
|
2023-12-30 17:38:08 +08:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2024-01-03 10:16:54 +08:00
|
|
|
func TestNewFuncConfig(t *testing.T) {
|
|
|
|
source := config.KisSource{
|
|
|
|
Name: "公众号抖音商城户订单数据",
|
|
|
|
Must: []string{"order_id", "user_id"},
|
|
|
|
}
|
|
|
|
|
|
|
|
option := config.KisFuncOption{
|
2024-03-01 16:29:07 +08:00
|
|
|
CName: "connectorName1",
|
|
|
|
RetryTimes: 3,
|
|
|
|
RetryDuration: 300,
|
2024-01-03 10:16:54 +08:00
|
|
|
|
|
|
|
Params: config.FParam{
|
|
|
|
"param1": "value1",
|
|
|
|
"param2": "value2",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
myFunc1 := config.NewFuncConfig("funcName1", common.S, &source, &option)
|
|
|
|
|
2024-04-07 22:39:21 +08:00
|
|
|
log.Logger().Info("funcName1", myFunc1)
|
2024-01-03 10:16:54 +08:00
|
|
|
}
|
|
|
|
|
2023-12-31 10:50:01 +08:00
|
|
|
func TestNewFlowConfig(t *testing.T) {
|
|
|
|
|
2024-01-01 17:49:27 +08:00
|
|
|
flowFuncParams1 := config.KisFlowFunctionParam{
|
2024-01-03 10:16:54 +08:00
|
|
|
FuncName: "funcName1",
|
2024-01-01 17:49:27 +08:00
|
|
|
Params: config.FParam{
|
2023-12-31 10:50:01 +08:00
|
|
|
"flowSetFunParam1": "value1",
|
|
|
|
"flowSetFunParam2": "value2",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-01-01 17:49:27 +08:00
|
|
|
flowFuncParams2 := config.KisFlowFunctionParam{
|
2024-01-03 10:16:54 +08:00
|
|
|
FuncName: "funcName2",
|
2024-01-01 17:49:27 +08:00
|
|
|
Params: config.FParam{
|
2023-12-31 10:50:01 +08:00
|
|
|
"default": "value1",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-01-03 10:16:54 +08:00
|
|
|
myFlow1 := config.NewFlowConfig("flowName1", common.FlowEnable)
|
2023-12-31 10:50:01 +08:00
|
|
|
myFlow1.AppendFunctionConfig(flowFuncParams1)
|
|
|
|
myFlow1.AppendFunctionConfig(flowFuncParams2)
|
|
|
|
|
2024-04-07 22:39:21 +08:00
|
|
|
log.Logger().Info("myFlow1", myFlow1)
|
2023-12-31 10:50:01 +08:00
|
|
|
}
|
|
|
|
|
2023-12-31 11:45:47 +08:00
|
|
|
func TestNewConnConfig(t *testing.T) {
|
|
|
|
|
2024-01-01 17:49:27 +08:00
|
|
|
source := config.KisSource{
|
2023-12-31 11:45:47 +08:00
|
|
|
Name: "公众号抖音商城户订单数据",
|
|
|
|
Must: []string{"order_id", "user_id"},
|
|
|
|
}
|
|
|
|
|
2024-01-01 17:49:27 +08:00
|
|
|
option := config.KisFuncOption{
|
2024-03-01 16:29:07 +08:00
|
|
|
CName: "connectorName1",
|
|
|
|
RetryTimes: 3,
|
|
|
|
RetryDuration: 300,
|
2023-12-31 11:45:47 +08:00
|
|
|
|
2024-01-01 17:49:27 +08:00
|
|
|
Params: config.FParam{
|
2023-12-31 11:45:47 +08:00
|
|
|
"param1": "value1",
|
|
|
|
"param2": "value2",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-01-03 10:16:54 +08:00
|
|
|
myFunc1 := config.NewFuncConfig("funcName1", common.S, &source, &option)
|
2023-12-31 11:45:47 +08:00
|
|
|
|
2024-01-01 17:49:27 +08:00
|
|
|
connParams := config.FParam{
|
2023-12-31 11:45:47 +08:00
|
|
|
"param1": "value1",
|
|
|
|
"param2": "value2",
|
|
|
|
}
|
|
|
|
|
2024-01-03 10:16:54 +08:00
|
|
|
myConnector1 := config.NewConnConfig("connectorName1", "0.0.0.0:9987,0.0.0.0:9997", common.REDIS, "key", connParams)
|
2023-12-31 11:45:47 +08:00
|
|
|
|
|
|
|
if err := myConnector1.WithFunc(myFunc1); err != nil {
|
2024-04-07 22:39:21 +08:00
|
|
|
log.Logger().Error("WithFunc", "err", err.Error())
|
2023-12-31 11:45:47 +08:00
|
|
|
}
|
|
|
|
|
2024-04-07 22:39:21 +08:00
|
|
|
log.Logger().Info("myConnector1", myConnector1)
|
2023-12-31 11:45:47 +08:00
|
|
|
}
|