modelRT/pool/concurrency_model_parse.go

38 lines
1.1 KiB
Go
Raw Normal View History

// Package pool define concurrency call function in ants
package pool
import (
"context"
"time"
"modelRT/config"
"modelRT/database"
"modelRT/diagram"
"modelRT/logger"
)
// ParseFunc defines func that parses the model data from postgres
var ParseFunc = func(parseConfig interface{}) {
modelParseConfig, ok := parseConfig.(config.ModelParseConfig)
if !ok {
logger.Error(modelParseConfig.Ctx, "conversion model parse config type failed")
2024-12-18 16:25:49 +08:00
return
}
cancelCtx, cancel := context.WithTimeout(modelParseConfig.Ctx, 5*time.Second)
defer cancel()
pgClient := database.GetPostgresDBClient()
component, err := database.QueryComponentByUUID(cancelCtx, pgClient, modelParseConfig.ComponentInfo.GlobalUUID)
if err != nil {
logger.Error(modelParseConfig.Ctx, "query component info failed", "error", err)
return
}
2024-12-18 16:25:49 +08:00
diagram.StoreAnchorValue(modelParseConfig.ComponentInfo.GlobalUUID.String(), "")
2024-12-18 16:25:49 +08:00
GetAnchorParamChan(modelParseConfig.Ctx, modelParseConfig.ComponentInfo.GlobalUUID.String())
2024-12-18 16:25:49 +08:00
diagram.StoreComponentMap(modelParseConfig.ComponentInfo.GlobalUUID.String(), &component)
return
}