MCPcopy Create free account
hub / github.com/clrxbl/blockgametracker / QueryAll

Function QueryAll

internal/ping/ping.go:116–147  ·  view source on GitHub ↗

QueryAll pings every enabled server across both editions concurrently and returns all successful results. Failed pings are logged and omitted.

(cfg config.Config)

Source from the content-addressed store, hash-verified

114// QueryAll pings every enabled server across both editions concurrently and
115// returns all successful results. Failed pings are logged and omitted.
116func QueryAll(cfg config.Config) []Result {
117 var (
118 wg sync.WaitGroup
119 mu sync.Mutex
120 results []Result
121 )
122
123 dispatch := func(servers []config.Server, edition string) {
124 for _, server := range servers {
125 if server.Disabled {
126 continue
127 }
128 wg.Add(1)
129 go func(s config.Server) {
130 defer wg.Done()
131 r := queryOne(edition, s.Name, s.Address)
132 if r == nil {
133 return
134 }
135 mu.Lock()
136 results = append(results, *r)
137 mu.Unlock()
138 }(server)
139 }
140 }
141
142 dispatch(cfg.Java, EditionJava)
143 dispatch(cfg.Bedrock, EditionBedrock)
144 wg.Wait()
145
146 return results
147}

Callers 2

mainFunction · 0.92
tickMethod · 0.92

Calls 1

queryOneFunction · 0.85

Tested by

no test coverage detected