MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / loadServerIdMap

Method loadServerIdMap

internal/metrics/task_kv.go:501–538  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

499}
500
501func (this *KVTask) loadServerIdMap() error {
502 var offsetKey string
503 var currentTime = this.itemConfig.CurrentTime()
504 for {
505 var found bool
506 err := this.sumTable.
507 Query().
508 Limit(1000).
509 Offset(offsetKey).
510 FindAll(func(tx *kvstore.Tx[[]byte], item kvstore.Item[[]byte]) (goNext bool, err error) {
511 offsetKey = item.Key
512 found = true
513
514 serverId, timeString, version, decodeErr := DecodeSumKey(item.Key)
515 if decodeErr != nil {
516 return false, decodeErr
517 }
518
519 if version != this.itemConfig.Version || timeString != currentTime {
520 return true, nil
521 }
522
523 this.serverIdMapLocker.Lock()
524 this.serverTimeMap[types.String(serverId)+"_"+timeString] = zero.New()
525 this.serverIdMapLocker.Unlock()
526
527 return true, nil
528 })
529 if err != nil {
530 return err
531 }
532 if !found {
533 break
534 }
535 }
536
537 return nil
538}

Callers 1

InitMethod · 0.95

Calls 9

NewFunction · 0.92
DecodeSumKeyFunction · 0.85
FindAllMethod · 0.80
OffsetMethod · 0.80
LimitMethod · 0.80
QueryMethod · 0.45
LockMethod · 0.45
StringMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected