modelRT/diagram/component_map.go

26 lines
643 B
Go
Raw Normal View History

package diagram
import (
"errors"
"fmt"
"sync"
cmap "github.com/orcaman/concurrent-map/v2"
)
2024-11-27 15:41:22 +08:00
// DiagramsOverview define struct of storage all circuit diagram data
var DiagramsOverview sync.Map
2024-11-27 15:41:22 +08:00
// GetComponentMap define func of get circuit diagram data by global uuid
func GetComponentMap(uuid string) (*cmap.ConcurrentMap[string, any], error) {
value, ok := DiagramsOverview.Load(uuid)
if !ok {
2024-11-27 15:41:22 +08:00
return nil, fmt.Errorf("can not find graph by global uuid:%s", uuid)
}
paramsMap, ok := value.(*cmap.ConcurrentMap[string, any])
if !ok {
return nil, errors.New("convert to component map struct failed")
}
return paramsMap, nil
}