MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / runHeavyRequestInGoroutine

Function runHeavyRequestInGoroutine

proxy_test.go:1303–1315  ·  view source on GitHub ↗

this function runs an number of heavyRequests using goroutines then waits that all the requests are currently handled by the fakeServer

(p *reverseProxy, nbHeavyRequest int64, shouldWait bool)

Source from the content-addressed store, hash-verified

1301// this function runs an number of heavyRequests using goroutines
1302// then waits that all the requests are currently handled by the fakeServer
1303func runHeavyRequestInGoroutine(p *reverseProxy, nbHeavyRequest int64, shouldWait bool) {
1304 atomic.StoreInt64(&nbHeavyRequestsInflight, 0)
1305 for i := 0; i < int(nbHeavyRequest); i++ {
1306 go makeHeavyRequest(p, heavyRequestDuration)
1307 }
1308 counter := 0
1309 //we wait up to 200 msec for the requests to be handled by the fakeServer because
1310 // the code on github actions can be very slow
1311 for shouldWait && atomic.LoadInt64(&nbHeavyRequestsInflight) < nbHeavyRequest && counter < 200 {
1312 time.Sleep(time.Millisecond)
1313 counter++
1314 }
1315}
1316
1317func stopAllRequestsInFlight() {
1318 atomic.StoreUint64(&shouldStop, 1)

Callers 1

Calls 1

makeHeavyRequestFunction · 0.85

Tested by

no test coverage detected