new respond to send all create change delete different bug fixes

This commit is contained in:
Adrian Zuercher
2025-07-23 09:10:56 +02:00
parent 8be5c80a22
commit c37dd87a37
6 changed files with 78 additions and 58 deletions

View File

@@ -87,18 +87,20 @@ func (d *DBM) UpdateDatapointValue(value any, uid uuid.UUID, path ...string) err
return d.Datapoints.UpdateDatapointValue(value, path[0])
}
func (d *DBM) RemoveDatapoint(sets ...json_dataModels.Set) ([]json_dataModels.Set, error) {
var lsRemoved []json_dataModels.Set
func (d *DBM) RemoveDatapoint(sets ...json_dataModels.Set) (lsRemoved []json_dataModels.Set, err error) {
for _, set := range sets {
removed, err := d.Datapoints.RemoveDatapoint(d.Conns, set)
if err != nil {
return lsRemoved, err
if set.Path == "" {
if dp, ok := d.Uuids[set.Uuid]; ok {
set.Path = dp.Path
}
}
lsRemoved = append(lsRemoved, removed)
d.ModifyCountedDatapoints(1, true)
lsRemoved, err = d.Datapoints.RemoveDatapoint(d.Conns, set)
if err != nil {
return
}
d.ModifyCountedDatapoints(uint64(len(lsRemoved)), true)
}
return lsRemoved, nil
return
}
func (d *DBM) QueryDatapoints(depth uint, uid uuid.UUID, key ...string) []*Datapoint {
@@ -159,8 +161,6 @@ func (d *DBM) GoSystemTime() error {
func (d *DBM) GoSystemMemory() error {
path := "System:UsedMemory"
var m runtime.MemStats
var mOld uint64
typ := json_dataModels.STR
rights := json_dataModels.Read
@@ -172,13 +172,11 @@ func (d *DBM) GoSystemMemory() error {
go func() {
for {
var m runtime.MemStats
runtime.ReadMemStats(&m)
if m.Sys != mOld {
mem := fmt.Sprintf("%.2f MB", float64(m.Sys)/1024/1024)
if er := d.UpdateDatapointValue(mem, uuid.Nil, path); er != nil {
d.Log.Error("dmb.Handler.AddSystemDps.UpdateDatapointValue", er.Error())
}
mOld = m.Sys
mem := fmt.Sprintf("%.2f MB", float64(m.Alloc)/1024/1024)
if er := d.UpdateDatapointValue(mem, uuid.Nil, path); er != nil {
d.Log.Error("dmb.Handler.AddSystemDps.UpdateDatapointValue", er.Error())
}
time.Sleep(time.Second)
}