Skip to content

Commit

Permalink
Merge branch 'master' into feature/aceld
Browse files Browse the repository at this point in the history
  • Loading branch information
aceld committed Apr 15, 2024
2 parents 3cc8a70 + 3f66d6a commit 517aa5b
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 92 deletions.
6 changes: 3 additions & 3 deletions config/kis_func_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewFuncConfig(
Name: "unNamedSource",
}
source = &defaultSource
log.Logger().InfoF("funcName NewConfig source is nil, funcName = %s, use default unNamed Source.", funcName)
log.Logger().Info("funcName NewConfig source is nil, use default unNamed Source.", "funcName", funcName)
}
config.Source = *source

Expand All @@ -56,10 +56,10 @@ func NewFuncConfig(
// FunctionS 和 L 需要必传KisConnector参数,原因是S和L需要通过Connector进行建立流式关系
if mode == common.S || mode == common.L {
if option == nil {
log.Logger().ErrorF("Funcion S/L need option->Cid\n")
log.Logger().Error("Funcion S/L need option->Cid\n")
return nil
} else if option.CName == "" {
log.Logger().ErrorF("Funcion S/L need option->Cid\n")
log.Logger().Error("Funcion S/L need option->Cid\n")
return nil
}
}
Expand Down
8 changes: 4 additions & 4 deletions flow/kis_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func (flow *KisFlow) Fork(ctx context.Context) kis.Flow {
}
}

log.Logger().DebugFX(ctx, "=====>Flow Fork, oldFlow.funcParams = %+v\n", flow.funcParams)
log.Logger().DebugFX(ctx, "=====>Flow Fork, newFlow.funcParams = %+v\n", newFlow.GetFuncParamsAllFuncs())
log.Logger().DebugX(ctx, "=====>Flow Fork, ", "oldFlow.funcParams", flow.funcParams)
log.Logger().DebugX(ctx, "=====>Flow Fork, ", "newFlow.funcParams", newFlow.GetFuncParamsAllFuncs())

return newFlow
}
Expand Down Expand Up @@ -257,7 +257,7 @@ func (flow *KisFlow) Run(ctx context.Context) error {

// 得到当前Function要处理与的源数据
if inputData, err := flow.getCurData(); err != nil {
log.Logger().ErrorFX(ctx, "flow.Run(): getCurData err = %s\n", err.Error())
log.Logger().ErrorX(ctx, "flow.Run(): getCurData", "err", err.Error())
return err
} else {
flow.inPut = inputData
Expand Down Expand Up @@ -350,7 +350,7 @@ func (flow *KisFlow) GetFuncConfigByName(funcName string) *config.KisFuncConfig
if f, ok := flow.Funcs[funcName]; ok {
return f.GetConfig()
} else {
log.Logger().ErrorF("GetFuncConfigByName(): Function %s not found", funcName)
log.Logger().Error("GetFuncConfigByName(): Function not found", "FunctionName", funcName)
return nil
}
}
12 changes: 6 additions & 6 deletions flow/kis_flow_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func (flow *KisFlow) commitSrcData(ctx context.Context) error {
// 统计数据总量 Metrics.DataTota 指标累计加1
metrics.Metrics.DataTotal.Add(float64(dataCnt))

//统计当前Flow数量指标
// 统计当前Flow数量指标
metrics.Metrics.FlowDataTotal.WithLabelValues(flow.Name).Add(float64(dataCnt))
}

log.Logger().DebugFX(ctx, "====> After CommitSrcData, flow_name = %s, flow_id = %s\nAll Level Data =\n %+v\n", flow.Name, flow.Id, flow.data)
log.Logger().DebugX(ctx, "====> After CommitSrcData", "flow_name", flow.Name, "flow_id", flow.Id, "All Level Data", flow.data)

return nil
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func (flow *KisFlow) commitReuseData(ctx context.Context) error {
// 清空缓冲Buf (如果是ReuseData选项,那么提交的全部数据,都将不会携带到下一层)
flow.buffer = flow.buffer[0:0]

log.Logger().DebugFX(ctx, " ====> After commitReuseData, flow_name = %s, flow_id = %s\nAll Level Data =\n %+v\n", flow.Name, flow.Id, flow.data)
log.Logger().DebugX(ctx, " ====> After commitReuseData", "flow_name", flow.Name, "flow_id", flow.Id, "All Level Data", flow.data)

return nil
}
Expand All @@ -122,12 +122,12 @@ func (flow *KisFlow) commitVoidData(ctx context.Context) error {
// 将本层计算的缓冲数据提交到本层结果数据中
flow.data[flow.ThisFunctionId] = batch

log.Logger().DebugFX(ctx, " ====> After commitVoidData, flow_name = %s, flow_id = %s\nAll Level Data =\n %+v\n", flow.Name, flow.Id, flow.data)
log.Logger().DebugX(ctx, " ====> After commitVoidData", "flow_name", flow.Name, "flow_id", flow.Id, "All Level Data", flow.data)

return nil
}

//commitCurData 提交Flow当前执行Function的结果数据
// commitCurData 提交Flow当前执行Function的结果数据
func (flow *KisFlow) commitCurData(ctx context.Context) error {

// 判断本层计算是否有结果数据,如果没有则退出本次Flow Run循环
Expand All @@ -150,7 +150,7 @@ func (flow *KisFlow) commitCurData(ctx context.Context) error {
// 清空缓冲Buf
flow.buffer = flow.buffer[0:0]

log.Logger().DebugFX(ctx, " ====> After commitCurData, flow_name = %s, flow_id = %s\nAll Level Data =\n %+v\n", flow.Name, flow.Id, flow.data)
log.Logger().DebugX(ctx, " ====> After commitCurData", "flow_name", flow.Name, "flow_id", flow.Id, "All Level Data", flow.data)

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions function/kis_function_c.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func NewKisFunctionC() kis.Function {
}

func (f *KisFunctionC) Call(ctx context.Context, flow kis.Flow) error {
log.Logger().DebugF("KisFunctionC, flow = %+v\n", flow)
log.Logger().Debug("KisFunctionC", "flow", flow)

// 通过KisPool 路由到具体的执行计算Function中
if err := kis.Pool().CallFunction(ctx, f.Config.FName, flow); err != nil {
log.Logger().ErrorFX(ctx, "Function Called Error err = %s\n", err)
log.Logger().ErrorX(ctx, "Function Called Error", "err", err)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions function/kis_function_e.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func NewKisFunctionE() kis.Function {
}

func (f *KisFunctionE) Call(ctx context.Context, flow kis.Flow) error {
log.Logger().DebugF("KisFunctionE, flow = %+v\n", flow)
log.Logger().Debug("KisFunctionE", "flow", flow)

// 通过KisPool 路由到具体的执行计算Function中
if err := kis.Pool().CallFunction(ctx, f.Config.FName, flow); err != nil {
log.Logger().ErrorFX(ctx, "Function Called Error err = %s\n", err)
log.Logger().ErrorX(ctx, "Function Called Error", "err", err)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions function/kis_function_l.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func NewKisFunctionL() kis.Function {
}

func (f *KisFunctionL) Call(ctx context.Context, flow kis.Flow) error {
log.Logger().DebugF("KisFunctionL, flow = %+v\n", flow)
log.Logger().Debug("KisFunctionL", "flow", flow)

// 通过KisPool 路由到具体的执行计算Function中
if err := kis.Pool().CallFunction(ctx, f.Config.FName, flow); err != nil {
log.Logger().ErrorFX(ctx, "Function Called Error err = %s\n", err)
log.Logger().ErrorX(ctx, "Function Called Error", "err", err)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions function/kis_function_s.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func NewKisFunctionS() kis.Function {
}

func (f *KisFunctionS) Call(ctx context.Context, flow kis.Flow) error {
log.Logger().DebugF("KisFunctionS, flow = %+v\n", flow)
log.Logger().Debug("KisFunctionS", "flow", flow)

// 通过KisPool 路由到具体的执行计算Function中
if err := kis.Pool().CallFunction(ctx, f.Config.FName, flow); err != nil {
log.Logger().ErrorFX(ctx, "Function Called Error err = %s\n", err)
log.Logger().ErrorX(ctx, "Function Called Error", "err", err)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions function/kis_function_v.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func NewKisFunctionV() kis.Function {
}

func (f *KisFunctionV) Call(ctx context.Context, flow kis.Flow) error {
log.Logger().DebugF("KisFunctionV, flow = %+v\n", flow)
log.Logger().Debug("KisFunctionV", "flow", flow)

// 通过KisPool 路由到具体的执行计算Function中
if err := kis.Pool().CallFunction(ctx, f.Config.FName, flow); err != nil {
log.Logger().ErrorFX(ctx, "Function Called Error err = %s\n", err)
log.Logger().ErrorX(ctx, "Function Called Error", "err", err)
return err
}

Expand Down
20 changes: 10 additions & 10 deletions kis/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _pool *kisPool
// Pool 单例构造
func Pool() *kisPool {
_poolOnce.Do(func() {
//创建kisPool对象
// 创建kisPool对象
_pool = new(kisPool)

// fnRouter初始化
Expand Down Expand Up @@ -61,7 +61,7 @@ func (pool *kisPool) AddFlow(name string, flow Flow) {
panic(errString)
}

log.Logger().InfoF("Add FlowRouter FlowName=%s", name)
log.Logger().Info("Add FlowRouter", "FlowName", name)
}

func (pool *kisPool) GetFlow(name string) Flow {
Expand Down Expand Up @@ -95,7 +95,7 @@ func (pool *kisPool) FaaS(fnName string, f FaaS) {
panic(errString)
}

log.Logger().InfoF("Add KisPool FuncName=%s", fnName)
log.Logger().Info("Add KisPool", "FuncName", fnName)
}

// CallFunction 调度 Function
Expand Down Expand Up @@ -127,7 +127,7 @@ func (pool *kisPool) CallFunction(ctx context.Context, fnName string, flow Flow)
// 将flow.Input()中的原始数据,反序列化为argType类型的数据
value, err := funcDesc.Serialize.UnMarshal(flow.Input(), argType)
if err != nil {
log.Logger().ErrorFX(ctx, "funcDesc.Serialize.DecodeParam err=%v", err)
log.Logger().ErrorX(ctx, "funcDesc.Serialize.DecodeParam", "err", err)
} else {
params = append(params, value)
continue
Expand All @@ -153,7 +153,7 @@ func (pool *kisPool) CallFunction(ctx context.Context, fnName string, flow Flow)

}

log.Logger().ErrorFX(ctx, "FuncName: %s Can not find in KisPool, Not Added.\n", fnName)
log.Logger().ErrorX(ctx, "FuncName: Can not find in KisPool, Not Added.", "FuncName", fnName)

return errors.New("FuncName: " + fnName + " Can not find in NsPool, Not Added.")
}
Expand All @@ -170,7 +170,7 @@ func (pool *kisPool) CaaSInit(cname string, c ConnInit) {
panic(errString)
}

log.Logger().InfoF("Add KisPool CaaSInit CName=%s", cname)
log.Logger().Info("Add KisPool CaaSInit", "CName", cname)
}

// CallConnInit 调度 ConnInit
Expand All @@ -193,10 +193,10 @@ func (pool *kisPool) CaaS(cname string, fname string, mode common.KisMode, c Caa
defer pool.cLock.Unlock()

if _, ok := pool.cTree[cname]; !ok {
//cid 首次注册,不存在,创建二级树NsConnSL
// cid 首次注册,不存在,创建二级树NsConnSL
pool.cTree[cname] = make(connSL)

//初始化各类型FunctionMode
// 初始化各类型FunctionMode
pool.cTree[cname][common.S] = make(connFuncRouter)
pool.cTree[cname][common.L] = make(connFuncRouter)
}
Expand All @@ -208,7 +208,7 @@ func (pool *kisPool) CaaS(cname string, fname string, mode common.KisMode, c Caa
panic(errString)
}

log.Logger().InfoF("Add KisPool CaaS CName=%s, FName=%s, Mode =%s", cname, fname, mode)
log.Logger().Info("Add KisPool CaaS", "CName", cname, "FName", fname, "Mode", mode)
}

// CallConnector 调度 Connector
Expand All @@ -223,7 +223,7 @@ func (pool *kisPool) CallConnector(ctx context.Context, flow Flow, conn Connecto
return callback(ctx, conn, fn, flow, args)
}

log.Logger().ErrorFX(ctx, "CName:%s FName:%s mode:%s Can not find in KisPool, Not Added.\n", conn.GetName(), fnConf.FName, mode)
log.Logger().ErrorX(ctx, "Can not find in KisPool, Not Added.", "CName", conn.GetName(), " FName", fnConf.FName, "mode", mode)

return nil, errors.New(fmt.Sprintf("CName:%s FName:%s mode:%s Can not find in KisPool, Not Added.", conn.GetName(), fnConf.FName, mode))
}
Expand Down
Loading

0 comments on commit 517aa5b

Please sign in to comment.