MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / InsertStat

Method InsertStat

internal/metrics/task_sqlite.go:268–291  ·  view source on GitHub ↗

InsertStat 写入数据

(stat *Stat)

Source from the content-addressed store, hash-verified

266
267// InsertStat 写入数据
268func (this *SQLiteTask) InsertStat(stat *Stat) error {
269 if this.isStopped {
270 return nil
271 }
272 if stat == nil {
273 return nil
274 }
275
276 this.serverIdMapLocker.Lock()
277 this.serverIdMap[stat.ServerId] = zero.New()
278 this.timeMap[stat.Time] = zero.New()
279 this.serverIdMapLocker.Unlock()
280
281 keyData, err := json.Marshal(stat.Keys)
282 if err != nil {
283 return err
284 }
285
286 _, err = this.insertStatStmt.Exec(stat.ServerId, stat.Hash, keyData, stat.Value, stat.Time, this.itemConfig.Version, stat.Value)
287 if err != nil {
288 return err
289 }
290 return nil
291}
292
293// CleanExpired 清理数据
294func (this *SQLiteTask) CleanExpired() error {

Callers 1

StartMethod · 0.95

Calls 4

NewFunction · 0.92
LockMethod · 0.45
UnlockMethod · 0.45
ExecMethod · 0.45

Tested by

no test coverage detected