MCPcopy
hub / github.com/apache/devlake / forceSendHttpRequest

Method forceSendHttpRequest

backend/test/helper/client.go:258–279  ·  view source on GitHub ↗
(retries uint, req *http.Request, onError func(err errors.Error) bool)

Source from the content-addressed store, hash-verified

256}
257
258func (d *DevlakeClient) forceSendHttpRequest(retries uint, req *http.Request, onError func(err errors.Error) bool) {
259 d.testCtx.Helper()
260 for {
261 res, err := http.DefaultClient.Do(req)
262 if err != nil {
263 if !onError(errors.Default.WrapRaw(err)) {
264 require.NoError(d.testCtx, err)
265 }
266 } else {
267 if res.StatusCode != http.StatusOK {
268 panic(fmt.Sprintf("received HTTP status %d", res.StatusCode))
269 }
270 return
271 }
272 retries--
273 if retries == 0 {
274 panic("retry limit exceeded")
275 }
276 fmt.Printf("retrying http call to %s\n", req.URL.String())
277 time.Sleep(1 * time.Second)
278 }
279}
280
281func (d *DevlakeClient) initPlugins(cfg *LocalClientConfig) {
282 d.testCtx.Helper()

Callers 1

ConnectLocalServerFunction · 0.95

Calls 4

DoMethod · 0.80
WrapRawMethod · 0.80
PrintfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected