Skip to content

Commit

Permalink
concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrizhu committed Nov 14, 2024
1 parent b48955e commit 58b690d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions lg.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ func (p *Prefix) checkLGState() {
for _, rrc := range ripeStatLookingGlassResp.Data.Rrcs {
upstreams := []string{}
upstreams2 := []string{}
communities := []string{}

for _, peer := range rrc.Peers {
communities = append(communities, peer.Community)
asPathSplit := strings.Split(peer.AsPath, " ")
upstream := ""
upstream2 := ""
Expand Down
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/signal"
"strconv"
"sync"
"syscall"
"time"

Expand All @@ -34,10 +35,17 @@ func updateStates() {

fetchRisPeer()

var wg sync.WaitGroup
wg.Add(len(monitorState))

for _, prefix := range monitorState {
prefix.checkVisState()
prefix.checkLGState()
go func() {
defer wg.Done()
prefix.checkVisState()
prefix.checkLGState()
}()
}
wg.Wait()
}

func init() {
Expand Down

0 comments on commit 58b690d

Please sign in to comment.