[feat]添加规则引擎debug功能

This commit is contained in:
PandaX
2023-10-27 15:28:29 +08:00
parent c2b16d5474
commit 0fcb262519
13 changed files with 2145 additions and 59 deletions

View File

@@ -0,0 +1,18 @@
package tdengine
import (
"fmt"
)
const debugTableName = "device_rule_debug"
func (s *TdEngine) CreateDeviceRuleDebugTable() (err error) {
sql := fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s.%s (ts TIMESTAMP,nodeId NCHAR(64),msgd NCHAR(64),debugType NCHAR(64),
deviceName NCHAR(64),msgType NCHAR(64),msg VARCHAR,metadata VARCHAR,error VARCHAR)`, s.dbName, debugTableName)
_, err = s.db.Exec(sql)
return
}
func (s *TdEngine) InsertRuleDebug(data map[string]any) (err error) {
return s.InsertDevice(debugTableName, data)
}