修复DataMap无法在多个节点之间共享的问题

This commit is contained in:
GoEdgeLab
2023-03-19 10:26:05 +08:00
parent a4b432401a
commit 6d5a30e882
3 changed files with 36 additions and 2 deletions

View File

@@ -967,6 +967,11 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, dataMap *shared
cacheMap = utils.NewCacheMap()
}
// 放入到缓存中,以便于后面继续使用
if dataMap != nil {
cacheMap.Put("DataMap", dataMap)
}
node, err := this.FindEnabledNode(tx, nodeId)
if err != nil {
return nil, err

View File

@@ -70,6 +70,19 @@ func TestNodeDAO_ComposeNodeConfig(t *testing.T) {
t.Fatal(err)
}
t.Log(len(data), "bytes")
{
nodeConfig, err = models.SharedNodeDAO.ComposeNodeConfig(tx, 148, dataMap, cacheMap)
if err != nil {
t.Fatal(err)
}
t.Log(len(nodeConfig.DataMap.Map), "items in dataMap")
data, err = json.Marshal(nodeConfig)
if err != nil {
t.Fatal(err)
}
t.Log(len(data), "bytes")
}
}
func TestNodeDAO_ComposeNodeConfig_ParentNodes(t *testing.T) {