modelRT/diagram/component_map.go

24 lines
491 B
Go

package diagram
import (
"errors"
"fmt"
"sync"
cmap "github.com/orcaman/concurrent-map/v2"
)
var DiagramsOverview sync.Map
func GetComponentMap(key string) (*cmap.ConcurrentMap[string, any], error) {
value, ok := DiagramsOverview.Load(key)
if !ok {
return nil, fmt.Errorf("can not find graph by pageID:%s", key)
}
paramsMap, ok := value.(*cmap.ConcurrentMap[string, any])
if !ok {
return nil, errors.New("convert to component map struct failed")
}
return paramsMap, nil
}