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