(ctx context.Context, httpClient *http.Client, username, password, method, path string, endpoints []string, requestBody []byte)
| 2103 | } |
| 2104 | |
| 2105 | func doHTTPAuthRequest(ctx context.Context, httpClient *http.Client, username, password, method, path string, endpoints []string, requestBody []byte) (statusCode int, responseBody []byte, err error) { |
| 2106 | retryCount := 0 |
| 2107 | |
| 2108 | worker := func() (shouldRetry bool, err error, value interface{}) { |
| 2109 | endpointIdx := retryCount % len(endpoints) |
| 2110 | responseBody, statusCode, err = base.MgmtRequest(httpClient, endpoints[endpointIdx], method, path, "", username, password, bytes.NewBuffer(requestBody)) |
| 2111 | |
| 2112 | if err, ok := err.(net.Error); ok && err.Timeout() { |
| 2113 | retryCount++ |
| 2114 | return true, err, nil |
| 2115 | } |
| 2116 | |
| 2117 | return false, err, nil |
| 2118 | } |
| 2119 | |
| 2120 | err, _ = base.RetryLoop(ctx, "doHTTPAuthRequest", worker, base.CreateSleeperFunc(10, 100)) |
| 2121 | if err != nil { |
| 2122 | return 0, nil, err |
| 2123 | } |
| 2124 | |
| 2125 | return statusCode, responseBody, nil |
| 2126 | } |
| 2127 | |
| 2128 | // For test use |
| 2129 | func (sc *ServerContext) Database(ctx context.Context, name string) *db.DatabaseContext { |
no test coverage detected